Dynamic Canvas - am I doing it right? #4093
-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
If calling Refresh on your widget does not actually refresh it usually means you missed the call to ExtendBaseWidget. Should not be any need to wrap it in a container just to get it working as expected. |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking a look. Here's a toy app that illustrates the problem, yet it has ExtendBaseWidget. The allocation of work between Layout and Refresh is a bit uncertain, since objects can come, go, and change at any time. But I have found no combination that helps. Everything works when you refresh a container, see the comments in the goroutine.
|
Beta Was this translation helpful? Give feedback.
-
Good point about immediate-mode! Can't see myself going there for a whole desktop app though. Further investigation (with circles; not sure how general it is) shows: widget.Refresh calls renderer.Refresh, but changes to objects are not picked up (as you said). The system knows if you cheat on Layout: just changing properties is not enough. If the subsequent Objects call returns the same list twice, it stops calling Layout until it wants a new size. Nice! So I am kind of forced into immediate mode to make the Layout look legitimate. Although re-creating one object gets them all redrawn, which suggests an evil (and likely fragile) efficiency trick. Anyway, all I need is an idiomatic way of saying RefreshYesNow; if that is poking an enclosing container and never returning the same object list twice, so be it. Maybe native widgets have it easier. If a Canvas widget (in the Tk sense) would be of general interest, I'll publish it once I believe it works by more than luck. |
Beta Was this translation helpful? Give feedback.
-
Terrific. I can confirm that |
Beta Was this translation helpful? Give feedback.
Just call
canvas.Refresh(render.myWidget)
and it will force a re-draw using the new info. Among other things that is what the container was doing but your renderer was not. That will ask it to re-paint without setting up a circular loop through the renderer Refresh call.