Struct gdk::FrameClock
source · [−]#[repr(transparent)]pub struct FrameClock { /* private fields */ }
Expand description
A FrameClock
tells the application when to update and repaint a
window. This may be synced to the vertical refresh rate of the
monitor, for example. Even when the frame clock uses a simple timer
rather than a hardware-based vertical sync, the frame clock helps
because it ensures everything paints at the same time (reducing the
total number of frames). The frame clock can also automatically
stop painting when it knows the frames will not be visible, or
scale back animation framerates.
FrameClock
is designed to be compatible with an OpenGL-based
implementation or with mozRequestAnimationFrame in Firefox,
for example.
A frame clock is idle until someone requests a frame with
request_phase()
. At some later point that makes
sense for the synchronization being implemented, the clock will
process a frame and emit signals for each phase that has been
requested. (See the signals of the FrameClock
class for
documentation of the phases. FrameClockPhase::UPDATE
and the
signal::FrameClock::update
signal are most interesting for application
writers, and are used to update the animations, using the frame time
given by frame_time()
.
The frame time is reported in microseconds and generally in the same
timescale as g_get_monotonic_time()
, however, it is not the same
as g_get_monotonic_time()
. The frame time does not advance during
the time a frame is being painted, and outside of a frame, an attempt
is made so that all calls to frame_time()
that
are called at a “similar” time get the same value. This means that
if different animations are timed by looking at the difference in
time between an initial value from frame_time()
and the value inside the signal::FrameClock::update
signal of the clock,
they will stay exactly synchronized.
This is an Abstract Base Class, you cannot instantiate it.
Implementations
sourceimpl FrameClock
impl FrameClock
sourcepub fn begin_updating(&self)
pub fn begin_updating(&self)
Starts updates for an animation. Until a matching call to
end_updating()
is made, the frame clock will continually
request a new frame with the FrameClockPhase::UPDATE
phase.
This function may be called multiple times and frames will be
requested until end_updating()
is called the same
number of times.
sourcepub fn end_updating(&self)
pub fn end_updating(&self)
Stops updates for an animation. See the documentation for
begin_updating()
.
sourcepub fn current_timings(&self) -> Option<FrameTimings>
pub fn current_timings(&self) -> Option<FrameTimings>
Gets the frame timings for the current frame.
Returns
the FrameTimings
for the
frame currently being processed, or even no frame is being
processed, for the previous frame. Before any frames have been
processed, returns None
.
sourcepub fn frame_counter(&self) -> i64
pub fn frame_counter(&self) -> i64
A FrameClock
maintains a 64-bit counter that increments for
each frame drawn.
Returns
inside frame processing, the value of the frame counter for the current frame. Outside of frame processing, the frame counter for the last frame.
sourcepub fn frame_time(&self) -> i64
pub fn frame_time(&self) -> i64
Gets the time that should currently be used for animations. Inside the processing of a frame, it’s the time used to compute the animation position of everything in a frame. Outside of a frame, it’s the time of the conceptual “previous frame,” which may be either the actual previous frame time, or if that’s too old, an updated time.
Returns
a timestamp in microseconds, in the timescale of
of g_get_monotonic_time()
.
sourcepub fn history_start(&self) -> i64
pub fn history_start(&self) -> i64
FrameClock
internally keeps a history of FrameTimings
objects for recent frames that can be retrieved with
timings()
. The set of stored frames
is the set from the counter values given by
history_start()
and
frame_counter()
, inclusive.
Returns
the frame counter value for the oldest frame
that is available in the internal frame history of the
FrameClock
.
sourcepub fn timings(&self, frame_counter: i64) -> Option<FrameTimings>
pub fn timings(&self, frame_counter: i64) -> Option<FrameTimings>
Retrieves a FrameTimings
object holding timing information
for the current frame or a recent frame. The FrameTimings
object may not yet be complete: see FrameTimings::is_complete()
.
frame_counter
the frame counter value identifying the frame to be received.
Returns
the FrameTimings
object for
the specified frame, or None
if it is not available. See
history_start()
.
sourcepub fn request_phase(&self, phase: FrameClockPhase)
pub fn request_phase(&self, phase: FrameClockPhase)
Asks the frame clock to run a particular phase. The signal
corresponding the requested phase will be emitted the next
time the frame clock processes. Multiple calls to
request_phase()
will be combined together
and only one frame processed. If you are displaying animated
content and want to continually request the
FrameClockPhase::UPDATE
phase for a period of time,
you should use begin_updating()
instead, since
this allows GTK+ to adjust system parameters to get maximally
smooth animations.
phase
the phase that is requested
sourcepub fn connect_after_paint<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_after_paint<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal ends processing of the frame. Applications should generally not handle this signal.
sourcepub fn connect_before_paint<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_before_paint<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal begins processing of the frame. Applications should generally not handle this signal.
sourcepub fn connect_flush_events<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_flush_events<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal is used to flush pending motion events that are being batched up and compressed together. Applications should not handle this signal.
sourcepub fn connect_layout<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
pub fn connect_layout<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
This signal is emitted as the second step of toolkit and application processing of the frame. Any work to update sizes and positions of application elements should be performed. GTK+ normally handles this internally.
sourcepub fn connect_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
pub fn connect_paint<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
This signal is emitted as the third step of toolkit and
application processing of the frame. The frame is
repainted. GDK normally handles this internally and
produces expose events, which are turned into GTK+
GtkWidget::draw
signals.
sourcepub fn connect_resume_events<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
pub fn connect_resume_events<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
This signal is emitted after processing of the frame is finished, and is handled internally by GTK+ to resume normal event processing. Applications should not handle this signal.
sourcepub fn connect_update<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
pub fn connect_update<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
This signal is emitted as the first step of toolkit and
application processing of the frame. Animations should
be updated using frame_time()
.
Applications can connect directly to this signal, or
use gtk_widget_add_tick_callback()
as a more convenient
interface.
sourceimpl FrameClock
impl FrameClock
sourcepub fn refresh_info(&self, base_time: i64) -> (i64, i64)
pub fn refresh_info(&self, base_time: i64) -> (i64, i64)
Using the frame history stored in the frame clock, finds the last
known presentation time and refresh interval, and assuming that
presentation times are separated by the refresh interval,
predicts a presentation time that is a multiple of the refresh
interval after the last presentation time, and later than base_time
.
base_time
base time for determining a presentaton time
Returns
refresh_interval_return
a location to store the
determined refresh interval, or None
. A default refresh interval of
1/60th of a second will be stored if no history is present.
presentation_time_return
a location to store the next candidate presentation time after the given base time. 0 will be will be stored if no history is present.
Trait Implementations
sourceimpl Clone for FrameClock
impl Clone for FrameClock
sourceimpl Debug for FrameClock
impl Debug for FrameClock
sourceimpl Display for FrameClock
impl Display for FrameClock
sourceimpl Hash for FrameClock
impl Hash for FrameClock
sourceimpl Ord for FrameClock
impl Ord for FrameClock
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl ParentClassIs for FrameClock
impl ParentClassIs for FrameClock
sourceimpl<OT: ObjectType> PartialEq<OT> for FrameClock
impl<OT: ObjectType> PartialEq<OT> for FrameClock
sourceimpl<OT: ObjectType> PartialOrd<OT> for FrameClock
impl<OT: ObjectType> PartialOrd<OT> for FrameClock
sourcefn partial_cmp(&self, other: &OT) -> Option<Ordering>
fn partial_cmp(&self, other: &OT) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl StaticType for FrameClock
impl StaticType for FrameClock
sourcefn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for FrameClock
Auto Trait Implementations
impl RefUnwindSafe for FrameClock
impl !Send for FrameClock
impl !Sync for FrameClock
impl Unpin for FrameClock
impl UnwindSafe for FrameClock
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Cast for Twhere
T: ObjectType,
impl<T> Cast for Twhere
T: ObjectType,
sourcefn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moresourcefn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moresourcefn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: CanDowncast<T>,
T
. Read moresourcefn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: CanDowncast<T>,
T
. Read moresourcefn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresourcefn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moresourceunsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
T
unconditionally. Read moresourceunsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
&T
unconditionally. Read moresourceimpl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
fn parent_instance_init<T>(instance: &mut InitializingObject<T>)where
T: ObjectSubclass,
<U as ParentClassIs>::Parent: IsSubclassable<T>,
sourceimpl<T> ObjectExt for Twhere
T: ObjectType,
impl<T> ObjectExt for Twhere
T: ObjectType,
sourcefn is<U>(&self) -> boolwhere
U: StaticType,
fn is<U>(&self) -> boolwhere
U: StaticType,
true
if the object is an instance of (can be cast to) T
.sourcefn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
ObjectClass
of the object. Read moresourcefn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
T
. Read moresourcefn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
T
of the object. Read moresourcefn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
fn set_property<V>(&self, property_name: &str, value: V)where
V: ToValue,
sourcefn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
sourcefn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
sourcefn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
sourcefn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
fn property<V>(&self, property_name: &str) -> Vwhere
V: 'static + for<'b> FromValue<'b>,
property_name
of the object and cast it to the type V. Read moresourcefn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
property_name
of the object. Read moresourcefn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
property_name
of this object. Read moresourcefn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
ParamSpec
of the property property_name
of this object.sourcefn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
ParamSpec
of the properties of this object.sourcefn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
sourceunsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
key
. Read moresourceunsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moresourceunsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
key
. Read moresourceunsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
key
. Read moresourceunsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moresourceunsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
key
. Read moresourcefn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
sourcefn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
sourcefn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
sourcefn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
sourcefn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_name
on this object. Read moresourcefn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
signal_id
on this object. Read moresourcefn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresourcefn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: 'static + Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresourceunsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_name
on this object. Read moresourceunsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F
) -> SignalHandlerIdwhere
F: Fn(&[Value]) -> Option<Value>,
signal_id
on this object. Read moresourcefn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_name
on this object. Read moresourcefn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure
) -> SignalHandlerId
signal_id
on this object. Read moresourcefn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
invoke_with_values
, or
invoke
when using Rust closures. Read moresourcefn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Self::emit
but takes Value
for the arguments.sourcefn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value]
) -> Option<Value>
sourcefn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value]
) -> Option<Value>
sourcefn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue]
) -> Rwhere
R: TryFromClosureReturnValue,
sourcefn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value]
) -> Option<Value>
sourcefn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
sourcefn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
notify
signal of the object. Read moresourcefn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerIdwhere
F: 'static + Fn(&T, &ParamSpec),
notify
signal of the object. Read moresourceunsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerIdwhere
F: Fn(&T, &ParamSpec),
notify
signal of the object. Read more