vizia icon indicating copy to clipboard operation
vizia copied to clipboard

Fixes for circle demo

Open GammaSagittarii opened this issue 2 years ago • 5 comments

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.

GammaSagittarii avatar Apr 12 '24 17:04 GammaSagittarii

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.

geom3trik avatar Apr 12 '24 19:04 geom3trik

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()

GammaSagittarii avatar Apr 13 '24 11:04 GammaSagittarii

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.

GammaSagittarii avatar Apr 16 '24 12:04 GammaSagittarii

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?

geom3trik avatar Apr 27 '24 14:04 geom3trik

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.

GammaSagittarii avatar Apr 28 '24 08:04 GammaSagittarii