makepad_widgets/
defer_with_redraw.rs

1use makepad_draw::ui_runner::{UiRunner, DeferCallback};
2use crate::Widget;
3
4
5/// Extension only aviailable when the `UiRunner` is used with a `Widget`.
6pub trait DeferWithRedraw<T: 'static> {
7    /// Same as `defer` but calls `redraw` on the widget after the closure is run.
8    fn defer_with_redraw(self, f: impl DeferCallback<T>);
9}
10
11impl<W: Widget + 'static> DeferWithRedraw<W> for UiRunner<W> {
12    fn defer_with_redraw(self, f: impl DeferCallback<W>) {
13        self.defer(|widget, cx, scope| {
14            f(widget, cx, scope);
15            widget.redraw(cx);
16        });
17    }
18}