Open chrisspre opened 2 years ago
You need to create the Image/TextLayout on LifeCycle::WidgetAdded
and then update it when needed in update()
Thanks. I will give that a try.
Is the "pattern" to store it via a Option on the widget's struct the right approach? Is there ways to avoid the Option, or a better place to cache?
we also use Option
in struct:
https://github.com/linebender/druid/blob/2d80ca04312746567219ebed2aacc0ee5d72b6c7/druid/src/widget/image.rs#L72-L78
LifeCycleCtx does not implement RenderCtx and therefore does not have a make_image method.
LifeCycleCtx does not implement RenderCtx and therefore does not have a make_image method.
Did you ever happen to find a solution to this?
Just store an Option<PietImage>
and populate it on first paint
Creating a custom widget with a quite a few Images and some TextLayouts.
I was able to create TextLayout/Image in Widget's update method , safe it in the Widget (as an Option<>) and then use it in the paint method. This seems like a hack and has the problem that the update method needs to be called once for it to work.
Is there a preferred way to cache the TextLayout/Image and avoid the overhead of creation in every paint?