boxy icon indicating copy to clipboard operation
boxy copied to clipboard

Finding child Offeset

Open kobyhallx opened this issue 2 years ago • 4 comments

I would like to be able to find Global Offset of a child of Widget nested down below in Widget.

So let's say I have following Widget tree:

W0 |--W01 |--W02 |--W03 W1 |--W11 |--W12 |--W13

I would like to layout W0 and W1, find Offset of W02 and W12 and inflate with widget which is positioned between W02 and W12.

What's the best way to do it?

I believe Boxy took me 1 step closer to achieving that but iterating over children to find their Offset seem problematic, approach I've taken is with

RenderBox rb = element.findRenderObject() as RenderBox;
connectorOffset = rb.localToGlobal(Offset.zero);

...but I'm told I should not read Offset this way by framework.

kobyhallx avatar Apr 04 '22 13:04 kobyhallx

Its not possible to read the offset of descendants because there is no way to guarantee that a child changing size will re-layout its grandparent.

Do you have a visual example of the layout you are trying to create?

pingbird avatar Apr 05 '22 01:04 pingbird

Would like to recreate Blender's Node Editor image

but with each Node starting as Scaffold.

kobyhallx avatar Apr 05 '22 12:04 kobyhallx

Is the end goal to draw that line between them? You can do that entirely in a painter, it's generally safe to access RenderObjects during the paint phase and the framework shouldn't stop you.

pingbird avatar Apr 07 '22 23:04 pingbird

...and so I did, now would like to draw those lines between Widgets, children to their parents. See those dots from screenshot, they would connect onto each other. I would need to find their Offset as their layout by the node Widget...

kobyhallx avatar Apr 08 '22 15:04 kobyhallx