Trait gtk4::prelude::WidgetExtManual
source · pub trait WidgetExtManual: Sealed + IsA<Widget> + 'static {
// Provided method
fn add_tick_callback<P: Fn(&Self, &FrameClock) -> ControlFlow + 'static>(
&self,
callback: P
) -> TickCallbackId { ... }
}
Expand description
Trait containing manually implemented methods of Widget
.
Provided Methods§
sourcefn add_tick_callback<P: Fn(&Self, &FrameClock) -> ControlFlow + 'static>(
&self,
callback: P
) -> TickCallbackId
fn add_tick_callback<P: Fn(&Self, &FrameClock) -> ControlFlow + 'static>( &self, callback: P ) -> TickCallbackId
Queues an animation frame update and adds a callback to be called before each frame.
Until the tick callback is removed, it will be called frequently
(usually at the frame rate of the output device or as quickly as
the application can be repainted, whichever is slower). For this
reason, is most suitable for handling graphics that change every
frame or every few frames. The tick callback does not automatically
imply a relayout or repaint. If you want a repaint or relayout, and
aren’t changing widget properties that would trigger that (for example,
changing the text of a Label
), then you will have to call
WidgetExt::queue_resize()
or WidgetExt::queue_draw()
yourself.
FrameClock::frame_time()
should generally be used
for timing continuous animations and
Gdk::FrameTimings::get_predicted_presentation_time()
if you are
trying to display isolated frames at particular times.
This is a more convenient alternative to connecting directly to the
update
signal of gdk::FrameClock
, since you
don’t have to worry about when a gdk::FrameClock
is assigned to a widget.
callback
function to call for updating animations
Returns
an id for the connection of this callback. Remove the callback
by passing the id returned from this function to
[WidgetExtManual::remove()
][crate::prelude::WidgetExtManual::remove()]