Fixes for circle demo
Reverted to using popup widget instead of dialog button, fixed menu not sending on_press event, and displaying coordinates in the popup for the circle radius size.
Looking good! However there is a scaling issue. The mouse coordinates are physical pixels but the layout system works in logical. You just need a cx.physical_to_logical() before the Pixels() parts.
Thank you, that is fixed now. But that made me realize that the circle position is reported in scaled coordinates.
Is there an easy way to get EventContext from Context?
I was unable to figure out how to call physical_to_logical in the map closure, as cx here is Contex and not EventContext in:
CircleDrawerData::circles_data .then(CircleData::circles) .get(cx) .get(selected) .map(|c| (c.x, c.y)) .unwrap()
I've figured out a workaround, by adding fields, x_logical and y_logical to the Circle, I can keep track of physical_to_logical values, and display that data. I think that adds unnecessary complexity to the demo, and displaying scaled coordinates is probably of no value anyway. Let me know what you think.
Apologies for the delay getting back to you, I was on holiday and then have been moving house. Could you not convert to logical before sending the event and have the stored coordinates in logical space?
No need to apologize, your timing is perfect. Before trying my workaround I tried to store coordinates in logical space but failed and got a nice app panic. I guess I was just having a bad day, because I managed to do it now, without much trouble.