diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/canvas-arena.cpp | 2 | ||||
| -rw-r--r-- | src/display/drawing-item.cpp | 11 | ||||
| -rw-r--r-- | src/display/drawing-shape.cpp | 7 | ||||
| -rw-r--r-- | src/display/drawing-shape.h | 2 | ||||
| -rw-r--r-- | src/display/drawing-text.cpp | 9 | ||||
| -rw-r--r-- | src/display/nr-style.cpp | 4 | ||||
| -rw-r--r-- | src/display/nr-style.h | 2 | ||||
| -rw-r--r-- | src/seltrans.cpp | 71 | ||||
| -rw-r--r-- | src/sp-ellipse.cpp | 73 | ||||
| -rw-r--r-- | src/style-internal.h | 15 | ||||
| -rw-r--r-- | src/verbs.cpp | 3 | ||||
| -rw-r--r-- | src/verbs.h | 2 |
12 files changed, 86 insertions, 115 deletions
diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 404a94828..25d35fc6b 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -227,7 +227,7 @@ sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ { SPCanvasArena *arena = SP_CANVAS_ARENA (item); - arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK); + arena->drawing.update(Geom::IntRect::infinite(), arena->ctx, DrawingItem::STATE_PICK | DrawingItem::STATE_BBOX); DrawingItem *picked = arena->drawing.pick(p, arena->drawing.delta, arena->sticky); arena->picked = picked; diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index ee52b4165..f2265a590 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -23,7 +23,6 @@ namespace Inkscape { -#ifdef WITH_CSSBLEND void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) { // All of the blend modes are implemented in Cairo as of 1.10. @@ -81,7 +80,6 @@ void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) { break; } } -#endif /** * @class DrawingItem @@ -409,7 +407,7 @@ DrawingItem::setItemBounds(Geom::OptRect const &bounds) * @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 + * propagating bounding box recomputation to children when the item's * transform changes. */ void @@ -594,9 +592,8 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag if (_cached) { if (_cache) { _cache->prepare(); -#ifdef WITH_CSSBLEND set_cairo_blend_operator( dc, _blend_mode ); -#endif + _cache->paintFromCache(dc, carea); if (!carea) return RENDER_OK; } else { @@ -625,10 +622,8 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag 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 -#ifdef WITH_CSSBLEND nir |= (_blend_mode != SP_CSS_BLEND_NORMAL); // 6. Blend mode not normal nir |= (_isolation == SP_CSS_ISOLATION_ISOLATE); // 7. Explicit isolatiom -#endif /* How the rendering is done. * @@ -740,9 +735,7 @@ DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flag } dc.rectangle(*carea); dc.setSource(&intermediate); -#ifdef WITH_CSSBLEND set_cairo_blend_operator( dc, _blend_mode ); -#endif dc.fill(); dc.setSource(0,0,0,0); // the call above is to clear a ref on the intermediate surface held by dc diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 92d71fad3..1a41bdb3a 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -149,7 +149,6 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u return STATE_ALL; } -#ifdef WITH_SVG2 void DrawingShape::_renderFill(DrawingContext &dc) { @@ -183,7 +182,6 @@ DrawingShape::_renderStroke(DrawingContext &dc) dc.newPath(); // clear path } } -#endif void DrawingShape::_renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) @@ -222,10 +220,9 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne } -#ifdef WITH_SVG2 if( _nrstyle.paint_order_layer[0] == NRStyle::PAINT_ORDER_NORMAL ) { // This is the most common case, special case so we don't call get_pathvector(), etc. twice -#endif + { // we assume the context has no path Inkscape::DrawingContext::Save save(dc); @@ -255,7 +252,6 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne _renderMarkers(dc, area, flags, stop_at); return RENDER_OK; -#ifdef WITH_SVG2 } // Handle different paint orders @@ -276,7 +272,6 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne } } return RENDER_OK; -#endif } void DrawingShape::_clipItem(DrawingContext &dc, Geom::IntRect const & /*area*/) diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index f37de9ce7..9d93a642f 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -39,10 +39,8 @@ protected: virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); -#ifdef WITH_SVG2 void _renderFill(DrawingContext &dc); void _renderStroke(DrawingContext &dc); -#endif void _renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at); diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index a280e221a..4178cb1d8 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -451,7 +451,6 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are Inkscape::DrawingContext::Save save(dc); dc.transform(_ctm); -#ifdef WITH_SVG2 // Text doesn't have markers, we can do paint-order quick and dirty. bool fill_first = false; if( _nrstyle.paint_order_layer[0] == NRStyle::PAINT_ORDER_NORMAL || @@ -461,22 +460,20 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are } // Won't get "stroke fill stroke" but that isn't 'valid' if (has_fill && fill_first) { -#else - if (has_fill) { -#endif _nrstyle.applyFill(dc); dc.fillPreserve(); } + if (has_stroke) { _nrstyle.applyStroke(dc); dc.strokePreserve(); } -#ifdef WITH_SVG2 + if (has_fill && !fill_first) { _nrstyle.applyFill(dc); dc.fillPreserve(); } -#endif + dc.newPath(); // clear path // draw text decoration diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 3d2d36483..09a28e63c 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -69,9 +69,7 @@ NRStyle::NRStyle() , line_through_position(0) , font_size(0) { -#ifdef WITH_SVG2 paint_order_layer[0] = PAINT_ORDER_NORMAL; -#endif } NRStyle::~NRStyle() @@ -165,7 +163,6 @@ void NRStyle::set(SPStyle *style) } -#ifdef WITH_SVG2 for( unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i) { switch (style->paint_order.layer[i]) { case SP_CSS_PAINT_ORDER_NORMAL: @@ -182,7 +179,6 @@ void NRStyle::set(SPStyle *style) break; } } -#endif text_decoration_line = TEXT_DECORATION_LINE_CLEAR; if(style->text_decoration_line.inherit ){ text_decoration_line |= TEXT_DECORATION_LINE_INHERIT; } diff --git a/src/display/nr-style.h b/src/display/nr-style.h index 8b5a0ee3d..ca880c00b 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -68,7 +68,6 @@ struct NRStyle { cairo_pattern_t *fill_pattern; cairo_pattern_t *stroke_pattern; -#ifdef WITH_SVG2 enum PaintOrderType { PAINT_ORDER_NORMAL, PAINT_ORDER_FILL, @@ -78,7 +77,6 @@ struct NRStyle { static const size_t PAINT_ORDER_LAYERS = 3; PaintOrderType paint_order_layer[PAINT_ORDER_LAYERS]; -#endif #define TEXT_DECORATION_LINE_CLEAR 0x00 #define TEXT_DECORATION_LINE_SET 0x01 diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 60a0bfa11..7708c999e 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -377,6 +377,12 @@ void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point c g_return_if_fail(_grabbed); g_return_if_fail(!_empty); + // E.g. scaling a perfectly vertical line in horizontal direction will not work, and will produce an identity affine + + if (rel_affine.isIdentity()) { + return; + } + Geom::Affine const affine( Geom::Translate(-norm) * rel_affine * Geom::Translate(norm) ); if (_show == SHOW_CONTENT) { @@ -389,6 +395,7 @@ void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point c } Geom::Affine const &prev_transform = _items_affines[i]; item.set_i2d_affine(prev_transform * affine); + // The new affine will only have been applied if the transformation is different from the previous one, see SPItem::set_item_transform } } else { if (_bbox) { @@ -439,21 +446,25 @@ void Inkscape::SelTrans::ungrab() _message_context.clear(); if (!_empty && _changed) { - sp_selection_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE)? true : false); - if (_center) { - *_center *= _current_relative_affine; - _center_is_set = true; - } + if (!_current_relative_affine.isIdentity()) { // we can have a identity affine + // when trying to stretch a perfectly vertical line in horizontal direction, which will not be allowed by the handles; -// If dragging showed content live, sp_selection_apply_affine cannot change the centers -// appropriately - it does not know the original positions of the centers (all objects already have -// the new bboxes). So we need to reset the centers from our saved array. - if (_show != SHOW_OUTLINE && !_current_relative_affine.isTranslation()) { - for (unsigned i = 0; i < _items_centers.size(); i++) { - SPItem *currentItem = _items[i]; - if (currentItem->isCenterSet()) { // only if it's already set - currentItem->setCenter (_items_centers[i] * _current_relative_affine); - currentItem->updateRepr(); + sp_selection_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE)? true : false); + if (_center) { + *_center *= _current_relative_affine; + _center_is_set = true; + } + + // If dragging showed content live, sp_selection_apply_affine cannot change the centers + // appropriately - it does not know the original positions of the centers (all objects already have + // the new bboxes). So we need to reset the centers from our saved array. + if (_show != SHOW_OUTLINE && !_current_relative_affine.isTranslation()) { + for (unsigned i = 0; i < _items_centers.size(); i++) { + SPItem *currentItem = _items[i]; + if (currentItem->isCenterSet()) { // only if it's already set + currentItem->setCenter (_items_centers[i] * _current_relative_affine); + currentItem->updateRepr(); + } } } } @@ -463,18 +474,22 @@ void Inkscape::SelTrans::ungrab() _items_affines.clear(); _items_centers.clear(); - if (_current_relative_affine.isTranslation()) { - DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - _("Move")); - } else if (_current_relative_affine.withoutTranslation().isScale()) { - DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - _("Scale")); - } else if (_current_relative_affine.withoutTranslation().isRotation()) { - DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - _("Rotate")); - } else { - DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, - _("Skew")); + if (!_current_relative_affine.isIdentity()) { // we can have a identity affine + // when trying to stretch a perfectly vertical line in horizontal direction, which will not be allowed + // by the handles; this would be identified as a (zero) translation by isTranslation() + if (_current_relative_affine.isTranslation()) { + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + _("Move")); + } else if (_current_relative_affine.withoutTranslation().isScale()) { + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + _("Scale")); + } else if (_current_relative_affine.withoutTranslation().isRotation()) { + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + _("Rotate")); + } else { + DocumentUndo::done(sp_desktop_document(_desktop), SP_VERB_CONTEXT_SELECT, + _("Skew")); + } } } else { @@ -506,7 +521,7 @@ void Inkscape::SelTrans::stamp() bool fixup = !_grabbed; if ( fixup && _stamp_cache ) { - // TODO - give a proper fix. Simple temproary work-around for the grab() issue + // TODO - give a proper fix. Simple temporary work-around for the grab() issue g_slist_free(_stamp_cache); _stamp_cache = NULL; } @@ -565,7 +580,7 @@ void Inkscape::SelTrans::stamp() } if ( fixup && _stamp_cache ) { - // TODO - give a proper fix. Simple temproary work-around for the grab() issue + // TODO - give a proper fix. Simple temporary work-around for the grab() issue g_slist_free(_stamp_cache); _stamp_cache = NULL; } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 25e4c07d7..cda59e057 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -419,62 +419,35 @@ void SPGenericEllipse::set_shape() // For simplicity, we use a circle with center (0, 0) and radius 1 for our calculations. Geom::Circle circle(0, 0, 1); - if (this->_isSlice()) { - Geom::Point center(0, 0); - Geom::Point start_point = Geom::Point::polar(start); - Geom::Point end_point = Geom::Point::polar(end); - Geom::Point middle_point = make_angle_bisector_ray(Geom::Ray(center, start), Geom::Ray(center, end)).versor(); - - Geom::EllipticalArc *arc = circle.arc(start_point, middle_point, end_point); - - Geom::Path path(start_point); - path.append(*arc); - - delete arc; - - Geom::PathBuilder pb; - pb.append(path); - - if (this->_closed) { - // "pizza slice" - pb.lineTo(center); - pb.closePath(); - } else { - // arc only - pb.flush(); - } - - curve = new SPCurve(pb.peek()); - } else { - // Full ellipse - // This code converts the circle to four elliptical arcs explicitly. - // Circle::getPath currently creates cubic bezier curves, these are not suitable here - // as a circle should have four mid markers at 0, 90, 180, 270 degrees. - Geom::Path path(Geom::Point::polar(0)); - Geom::EllipticalArc* arc; - - arc = circle.arc(Geom::Point::polar(0), Geom::Point::polar(M_PI / 4.0), Geom::Point::polar(M_PI / 2.0)); - path.append(*arc); - delete arc; - - arc = circle.arc(Geom::Point::polar(M_PI / 2.0), Geom::Point::polar(3.0 * M_PI / 4.0), Geom::Point::polar(M_PI)); - path.append(*arc); - delete arc; + if (!this->_isSlice()) { + start = 0.0; + end = 2.0*M_PI; + } + double incr = end - start; // arc angle + if (incr < 0.0) incr += 2.0*M_PI; - arc = circle.arc(Geom::Point::polar(M_PI), Geom::Point::polar(5.0 * M_PI / 4.0), Geom::Point::polar(3.0 * M_PI / 2.0)); - path.append(*arc); - delete arc; + int numsegs = 1 + int(incr*2.0/M_PI); // number of arc segments + if (numsegs > 4) numsegs = 4; - arc = circle.arc(Geom::Point::polar(3.0 * M_PI / 2.0), Geom::Point::polar(7.0 * M_PI / 4.0), Geom::Point::polar(2.0 * M_PI)); + incr = incr/numsegs; // limit arc angle to less than 90 degrees + Geom::Path path(Geom::Point::polar(start)); + Geom::EllipticalArc* arc; + for (int seg = 0; seg < numsegs; seg++) { + arc = circle.arc(Geom::Point::polar(start + seg*incr), Geom::Point::polar(start + (seg + 0.5)*incr), Geom::Point::polar(start + (seg + 1.0)*incr)); path.append(*arc); delete arc; - - Geom::PathBuilder pb; - pb.append(path); + } + Geom::PathBuilder pb; + pb.append(path); + if (this->_isSlice() && this->_closed) { + pb.lineTo(Geom::Point(0, 0)); + } + if (this->_closed) { pb.closePath(); - - curve = new SPCurve(pb.peek()); + } else { + pb.flush(); } + curve = new SPCurve(pb.peek()); // gchar *str = sp_svg_write_path(curve->get_pathvector()); // std::cout << " path: " << str << std::endl; diff --git a/src/style-internal.h b/src/style-internal.h index d1a331acf..e9cf6e604 100644 --- a/src/style-internal.h +++ b/src/style-internal.h @@ -128,6 +128,7 @@ class SPIBase { set = rhs.set; inherit = rhs.inherit; style_att = rhs.style_att; + style = rhs.style; return *this; } @@ -166,7 +167,7 @@ class SPIFloat : public SPIBase { SPIFloat& operator=(const SPIFloat& rhs) { SPIBase::operator=(rhs); value = rhs.value; - value_default = value_default; + value_default = rhs.value_default; return *this; } @@ -229,7 +230,8 @@ class SPIScale24 : public SPIBase { SPIScale24& operator=(const SPIScale24& rhs) { SPIBase::operator=(rhs); - value = rhs.value; + value = rhs.value; + value_default = rhs.value_default; return *this; } @@ -389,7 +391,7 @@ class SPIString : public SPIBase { SPIBase( name ) , value(NULL) , value_default(NULL) { value_default = value_default_in?g_strdup(value_default_in):NULL; }; - virtual ~SPIString() { g_free(value); }; + virtual ~SPIString() { g_free(value); g_free(value_default); }; virtual void read( gchar const *str ); virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET, SPIBase const *const base = NULL ) const; @@ -399,7 +401,10 @@ class SPIString : public SPIBase { SPIString& operator=(const SPIString& rhs) { SPIBase::operator=(rhs); + g_free(value); + g_free(value_default); value = rhs.value?g_strdup(rhs.value):NULL; + value_default = rhs.value_default?g_strdup(rhs.value_default):NULL; return *this; } @@ -428,7 +433,8 @@ class SPIColor : public SPIBase { SPIColor& operator=(const SPIColor& rhs) { SPIBase::operator=(rhs); - value.color = rhs.value.color; + currentcolor = rhs.currentcolor; + value.color = rhs.value.color; return *this; } @@ -556,6 +562,7 @@ class SPIPaintOrder : public SPIBase { layer[i] = rhs.layer[i]; layer_set[i] = rhs.layer_set[i]; } + g_free(value); value = g_strdup(rhs.value); return *this; } diff --git a/src/verbs.cpp b/src/verbs.cpp index 10814cea1..c20f48e65 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -2374,8 +2374,7 @@ Verb *Verb::_base_verbs[] = { 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")), - 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_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 Clip Art..."), N_("Import clipart 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), diff --git a/src/verbs.h b/src/verbs.h index 86613b246..141a9c7e9 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -52,7 +52,7 @@ enum { SP_VERB_FILE_PRINT, SP_VERB_FILE_VACUUM, SP_VERB_FILE_IMPORT, - SP_VERB_FILE_EXPORT, +// SP_VERB_FILE_EXPORT, SP_VERB_FILE_IMPORT_FROM_OCAL, /**< Import the file from Open Clip Art Library */ // SP_VERB_FILE_EXPORT_TO_OCAL, /**< Export the file to Open Clip Art Library */ SP_VERB_FILE_NEXT_DESKTOP, |
