Roassal3 icon indicating copy to clipboard operation
Roassal3 copied to clipboard

RSComposite>>#adjustToChildren is wrong

Open pavel-krivanek opened this issue 3 years ago • 6 comments

I got an interesting case where calling twice the adjustToChildren made different results and I think the logic of this method is wrong.

We have a composite shape and some children that are not symetrically spread around its center. This method first computes the encompassing rectangle of all the children (one in this case) and then computes the delta relative to the center of the coordinate system.

image

The position of the children in respect to the parent composite shape is 0@0.

Now, if you execute adjustToChildren for the second time. The delta is computed again. And because the child position matrix is related to the parent composite, it is 0@0.. But now the translation of the composite itself is performed anyway (translateTo: delta negated) which means that the composite center is now at 0@0. And so it shifts all the visible shapes.

pavel-krivanek avatar Jun 10 '22 07:06 pavel-krivanek

Hi @pavel-krivanek what should be the expected behaviour for adjustToChildren?

akevalion avatar Jun 10 '22 08:06 akevalion

Hi, The results are IMHO not wrong but it should be consistent. Evaluating it twice should have all the time the same result.

pavel-krivanek avatar Jun 10 '22 09:06 pavel-krivanek

I have added this test testAdjustChildrenTwice

akevalion avatar Jun 10 '22 09:06 akevalion

Please let me know if this solves the issue

akevalion avatar Jun 10 '22 13:06 akevalion

Moved to pharo-graphics/Roassal

akevalion avatar Nov 10 '23 15:11 akevalion

Restored to Roassal3

akevalion avatar Jan 05 '24 15:01 akevalion