summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/selection-chemistry.cpp7
-rw-r--r--src/sp-item-group.cpp3
-rw-r--r--src/sp-item.cpp5
-rw-r--r--src/sp-item.h1
4 files changed, 13 insertions, 3 deletions
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 868a9d743..f058189d3 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -1621,10 +1621,13 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
item->doWriteTransform(item->getRepr(), item->transform, NULL, compensate);
}
- // if we're moving the actual object, not just updating the repr, we can transform the
+ // if we're transforming the actual object, not just updating the repr, we can transform the
// center by the same matrix (only necessary for non-translations)
if (set_i2d && item->isCenterSet() && !(affine.isTranslation() || affine.isIdentity())) {
- item->setCenter(old_center * affine);
+ // If there's a viewbox, we might have an affine with a translation component;
+ // we will only apply the scaling/skewing components, not the translations
+ // because otherwise the center will move relative to the item
+ item->setCenter(old_center * affine.withoutTranslation());
item->updateRepr();
}
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 2cfe97db8..7af4e3320 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -664,7 +664,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p)
Geom::Point old_center(0,0);
if (item->isCenterSet()) {
- old_center = item->getCenter();
+ item->scaleCenter(sc.inverse()); // Convert the old relative center position to the new coordinates already now
+ old_center = item->getCenter(); // because getCenter() will use the bbox midpoint, which is also already in the new coordinates
}
gchar const *conn_type = NULL;
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index b10aae1c6..0cdff6546 100644
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
@@ -271,6 +271,11 @@ Geom::Point SPItem::getCenter() const {
}
}
+void
+SPItem::scaleCenter(Geom::Scale const &sc) {
+ transform_center_x *= sc[Geom::X];
+ transform_center_y *= sc[Geom::Y];
+}
namespace {
diff --git a/src/sp-item.h b/src/sp-item.h
index d605c99b9..ce93b1d40 100644
--- a/src/sp-item.h
+++ b/src/sp-item.h
@@ -159,6 +159,7 @@ public:
void unsetCenter();
bool isCenterSet() const;
Geom::Point getCenter() const;
+ void scaleCenter(Geom::Scale const &sc);
bool isVisibleAndUnlocked() const;