@@ -1386,6 +1386,16 @@ void TestQgsLayoutItem::page()
1386
1386
QCOMPARE ( item->page (), 2 );
1387
1387
QCOMPARE ( item->pagePositionWithUnits (), QgsLayoutPoint ( 5 , 6 , QgsUnitTypes::LayoutCentimeters ) );
1388
1388
QCOMPARE ( item->positionWithUnits (), QgsLayoutPoint ( 5 , 38 , QgsUnitTypes::LayoutCentimeters ) );
1389
+
1390
+ // non-top-left reference
1391
+ item->setReferencePoint ( QgsLayoutItem::Middle );
1392
+ item->attemptMove ( QgsLayoutPoint ( 5 , 6 ), true , false , 0 );
1393
+ QCOMPARE ( item->pagePos (), QPointF ( 5 , 6 ) );
1394
+ QCOMPARE ( item->pagePositionWithUnits (), QgsLayoutPoint ( 5 , 6 ) );
1395
+ item->attemptMove ( QgsLayoutPoint ( 5 , 6 ), true , false , 1 );
1396
+ QCOMPARE ( item->page (), 1 );
1397
+ QCOMPARE ( item->pagePos (), QPointF ( 5 , 6 ) );
1398
+ QCOMPARE ( item->pagePositionWithUnits (), QgsLayoutPoint ( 5 , 6 , QgsUnitTypes::LayoutMillimeters ) );
1389
1399
}
1390
1400
1391
1401
void TestQgsLayoutItem::itemVariablesFunction ()
@@ -1525,6 +1535,24 @@ void TestQgsLayoutItem::rotation()
1525
1535
QCOMPARE ( item2->pos ().x (), 7.0 );
1526
1536
QCOMPARE ( item2->pos ().y (), 16.0 );
1527
1537
1538
+ // test that refresh rotation doesn't move item (#18037)
1539
+ item2 = qgis::make_unique< TestItem >( &l );
1540
+ item2->setReferencePoint ( QgsLayoutItem::Middle );
1541
+ item2->attemptMove ( QgsLayoutPoint ( 5.0 , 8.0 ) );
1542
+ item2->attemptResize ( QgsLayoutSize ( 10.0 , 6.0 ) );
1543
+ item2->setItemRotation ( 45 );
1544
+ QCOMPARE ( item2->positionWithUnits ().x (), 5.0 );
1545
+ QCOMPARE ( item2->positionWithUnits ().y (), 8.0 );
1546
+ QGSCOMPARENEAR ( item2->pos ().x (), 3.58 , 0.01 );
1547
+ QGSCOMPARENEAR ( item2->pos ().y (), 2.343146 , 0.01 );
1548
+ QCOMPARE ( item2->rotation (), 45.0 );
1549
+ item2->refresh ();
1550
+ QCOMPARE ( item2->positionWithUnits ().x (), 5.0 );
1551
+ QCOMPARE ( item2->positionWithUnits ().y (), 8.0 );
1552
+ QGSCOMPARENEAR ( item2->pos ().x (), 3.58 , 0.01 );
1553
+ QGSCOMPARENEAR ( item2->pos ().y (), 2.343146 , 0.01 );
1554
+ QCOMPARE ( item2->rotation (), 45.0 );
1555
+
1528
1556
1529
1557
// TODO also changing size?
1530
1558
0 commit comments