summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-09-11 03:50:49 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-09-11 03:50:49 +0000
commit282e965e030e7a1e9ae3455f877f7e8f8e1ea8dd (patch)
tree572b1097db43a42c1fb44a78f107c459e2c524ec /src
parentFix bug that added transforms to new objects. (diff)
downloadinkscape-282e965e030e7a1e9ae3455f877f7e8f8e1ea8dd.tar.gz
inkscape-282e965e030e7a1e9ae3455f877f7e8f8e1ea8dd.zip
Fix document unit change for 3d boxes and (mostly) for text on path.
(bzr r12475.1.12)
Diffstat (limited to 'src')
-rw-r--r--src/sp-item-group.cpp43
-rw-r--r--src/sp-text.cpp11
-rw-r--r--src/sp-text.h7
3 files changed, 50 insertions, 11 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 1b3a53828..ec368bbac 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -52,6 +52,7 @@
#include "verbs.h"
#include "layer-model.h"
#include "selection-chemistry.h"
+#include "sp-textpath.h"
using Inkscape::DocumentUndo;
@@ -569,22 +570,46 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p)
if ( hasChildren() ) {
for (SPObject *o = firstChild() ; o ; o = o->getNext() ) {
if ( SP_IS_ITEM(o) ) {
- if (SP_IS_GROUP(o)) {
+ if (SP_IS_GROUP(o) && !SP_IS_BOX3D(o)) {
SP_GROUP(o)->scaleChildItemsRec(sc, p);
} else {
- SPItem *item = reinterpret_cast<SPItem *>(o);
+ SPItem *item = SP_ITEM(o);
Geom::OptRect bbox = item->desktopVisualBounds();
if (bbox) {
- // Clear selection (TODO: save and restore selection)
- sp_desktop_selection(SP_ACTIVE_DESKTOP)->clear();
-
// Scale item
Geom::Translate const s(p);
Geom::Affine final = s.inverse() * sc * s;
- Inkscape::LayerModel layers = Inkscape::LayerModel();
- Inkscape::Selection selection(&layers, SP_ACTIVE_DESKTOP);
- selection.add(item);
- sp_selection_apply_affine(&selection, final, true, true);
+
+ Geom::Point old_center(0,0);
+ if (item->isCenterSet()) {
+ old_center = item->getCenter();
+ }
+
+ if (SP_IS_TEXT_TEXTPATH(item) && item->transform.isIdentity()) {
+ if (item->transform.isIdentity()) {
+ SP_TEXT(item)->optimizeTextpathText();
+ } else {
+ // TODO: transformed text on textpath
+ }
+ }
+
+ if (SP_IS_BOX3D(item)) {
+ // Force recalculation from perspective
+ box3d_position_set(SP_BOX3D(item));
+ } else if (SP_IS_USE(item)) {
+ // calculate the matrix we need to apply to the clone
+ // to cancel its induced transform from its original
+ Geom::Affine move = final.inverse() * item->transform * final;
+ item->doWriteTransform(item->getRepr(), move, &move, true);
+ } else {
+ item->set_i2d_affine(item->i2dt_affine() * final);
+ item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ }
+
+ if (item->isCenterSet() && !(final.isTranslation() || final.isIdentity())) {
+ item->setCenter(old_center * final);
+ item->updateRepr();
+ }
}
}
}
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index 2e2bf15bc..05a1827fe 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -109,6 +109,8 @@ sp_text_init (SPText *text)
{
new (&text->layout) Inkscape::Text::Layout;
new (&text->attributes) TextTagAttributes;
+
+ text->_optimizeTextpathText = false;
}
static void
@@ -427,8 +429,13 @@ sp_text_set_transform (SPItem *item, Geom::Affine const &xform)
SPText *text = SP_TEXT(item);
// we cannot optimize textpath because changing its fontsize will break its match to the path
- if (SP_IS_TEXT_TEXTPATH (text))
- return xform;
+ if (SP_IS_TEXT_TEXTPATH (text)) {
+ if (!text->_optimizeTextpathText) {
+ return xform;
+ } else {
+ text->_optimizeTextpathText = false;
+ }
+ }
/* This function takes care of scaling & translation only, we return whatever parts we can't
handle. */
diff --git a/src/sp-text.h b/src/sp-text.h
index 457f11f06..aa80c18b2 100644
--- a/src/sp-text.h
+++ b/src/sp-text.h
@@ -59,6 +59,8 @@ struct SPText : public SPItem {
/** discards the drawing objects representing this text. */
void _clearFlow(Inkscape::DrawingGroup *in_arena);
+ bool _optimizeTextpathText;
+
private:
/** Recursively walks the xml tree adding tags and their contents. The
non-trivial code does two things: firstly, it manages the positioning
@@ -66,6 +68,11 @@ private:
breaks and makes sure both that they are assigned the correct SPObject and
that we don't get a spurious extra one at the end of the flow. */
unsigned _buildLayoutInput(SPObject *root, Inkscape::Text::Layout::OptionalTextTagAttrs const &parent_optional_attrs, unsigned parent_attrs_offset, bool in_textpath);
+
+public:
+ /** Optimize textpath text on next set_transform. */
+ void optimizeTextpathText()
+ {_optimizeTextpathText = true;}
};
struct SPTextClass {