@@ -1207,11 +1207,25 @@ class LayerProperties : public ObjectProperties
1207
1207
tr (" Offset" ),
1208
1208
[this ] { return layer ()->offset (); },
1209
1209
[this ](const QPointF &value) {
1210
- // todo: consider whether we can apply only the changed axis to the selected layers
1211
- // this is what PropertyBrowser::applyLayerValue used to do
1210
+ const auto oldValue = layer ()->offset ();
1211
+ const bool changedX = oldValue.x () != value.x ();
1212
+ const bool changedY = oldValue.y () != value.y ();
1213
+
1214
+ QVector<QPointF> offsets;
1215
+ for (const Layer *layer : mapDocument ()->selectedLayers ())
1216
+ offsets.append (layer->offset ());
1217
+
1218
+ if (changedX) {
1219
+ for (QPointF &offset : offsets)
1220
+ offset.setX (value.x ());
1221
+ } else if (changedY) {
1222
+ for (QPointF &offset : offsets)
1223
+ offset.setY (value.y ());
1224
+ }
1225
+
1212
1226
push (new SetLayerOffset (mapDocument (),
1213
1227
mapDocument ()->selectedLayers (),
1214
- value ));
1228
+ offsets ));
1215
1229
});
1216
1230
1217
1231
mParallaxFactorProperty = new PointFProperty (
@@ -1771,20 +1785,29 @@ class MapObjectProperties : public ObjectProperties
1771
1785
return mapObject ()->cell ().flags ();
1772
1786
},
1773
1787
[this ](const int &value) {
1774
- const int flippingFlags = value;
1775
-
1776
- MapObjectCell mapObjectCell;
1777
- mapObjectCell.object = mapObject ();
1778
- mapObjectCell.cell = mapObject ()->cell ();
1779
- mapObjectCell.cell .setFlippedHorizontally (flippingFlags & 1 );
1780
- mapObjectCell.cell .setFlippedVertically (flippingFlags & 2 );
1788
+ const int oldValue = mapObject ()->cell ().flags ();
1789
+ const bool changedHorizontally = (oldValue & 1 ) != (value & 1 );
1790
+ const bool changedVertically = (oldValue & 2 ) != (value & 2 );
1791
+
1792
+ QVector<MapObjectCell> objectChanges;
1793
+
1794
+ for (MapObject *object : mapDocument ()->selectedObjects ()) {
1795
+ MapObjectCell mapObjectCell;
1796
+ mapObjectCell.object = object;
1797
+ mapObjectCell.cell = object->cell ();
1798
+ if (changedHorizontally)
1799
+ mapObjectCell.cell .setFlippedHorizontally (value & 1 );
1800
+ if (changedVertically)
1801
+ mapObjectCell.cell .setFlippedVertically (value & 2 );
1802
+ objectChanges.append (mapObjectCell);
1803
+ }
1781
1804
1782
- auto command = new ChangeMapObjectCells (mDocument , { mapObjectCell } );
1805
+ auto command = new ChangeMapObjectCells (mDocument , objectChanges );
1783
1806
1784
1807
command->setText (QCoreApplication::translate (" Undo Commands" ,
1785
1808
" Flip %n Object(s)" ,
1786
1809
nullptr ,
1787
- mapDocument ()-> selectedObjects () .size ()));
1810
+ objectChanges .size ()));
1788
1811
push (command);
1789
1812
});
1790
1813
@@ -1938,7 +1961,29 @@ class MapObjectProperties : public ObjectProperties
1938
1961
1939
1962
void changeMapObject (MapObject::Property property, const QVariant &value)
1940
1963
{
1941
- push (new ChangeMapObject (mapDocument (), mapObject (), property, value));
1964
+ // todo: when changing object position or size, only change the
1965
+ // selected objects in the respective axis or dimension
1966
+ QUndoCommand *command = new ChangeMapObject (mapDocument (), mapObject (),
1967
+ property, value);
1968
+
1969
+ if (mapDocument ()->selectedObjects ().size () == 1 ) {
1970
+ push (command);
1971
+ return ;
1972
+ }
1973
+
1974
+ auto undoStack = mDocument ->undoStack ();
1975
+ undoStack->beginMacro (command->text ());
1976
+ undoStack->push (command);
1977
+
1978
+ for (MapObject *obj : mapDocument ()->selectedObjects ()) {
1979
+ if (obj != mapObject ()) {
1980
+ QUndoCommand *cmd = new ChangeMapObject (mapDocument (), obj,
1981
+ property, value);
1982
+ undoStack->push (cmd);
1983
+ }
1984
+ }
1985
+
1986
+ mDocument ->undoStack ()->endMacro ();
1942
1987
}
1943
1988
1944
1989
GroupProperty *mObjectProperties ;
0 commit comments