Trait gdk4::prelude::PaintableExt
source · pub trait PaintableExt: IsA<Paintable> + Sealed + 'static {
// Provided methods
fn compute_concrete_size(
&self,
specified_width: f64,
specified_height: f64,
default_width: f64,
default_height: f64
) -> (f64, f64) { ... }
fn current_image(&self) -> Paintable { ... }
fn flags(&self) -> PaintableFlags { ... }
fn intrinsic_aspect_ratio(&self) -> f64 { ... }
fn intrinsic_height(&self) -> i32 { ... }
fn intrinsic_width(&self) -> i32 { ... }
fn invalidate_contents(&self) { ... }
fn invalidate_size(&self) { ... }
fn snapshot(&self, snapshot: &impl IsA<Snapshot>, width: f64, height: f64) { ... }
fn connect_invalidate_contents<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
fn connect_invalidate_size<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
sourcefn compute_concrete_size(
&self,
specified_width: f64,
specified_height: f64,
default_width: f64,
default_height: f64
) -> (f64, f64)
fn compute_concrete_size( &self, specified_width: f64, specified_height: f64, default_width: f64, default_height: f64 ) -> (f64, f64)
Compute a concrete size for the Paintable
.
Applies the sizing algorithm outlined in the CSS Image spec to the given @self. See that link for more details.
It is not necessary to call this function when both @specified_width and @specified_height are known, but it is useful to call this function in GtkWidget:measure implementations to compute the other dimension when only one dimension is given.
specified_width
the width @self could be drawn into or 0.0 if unknown
specified_height
the height @self could be drawn into or 0.0 if unknown
default_width
the width @self would be drawn into if no other constraints were given
default_height
the height @self would be drawn into if no other constraints were given
Returns
concrete_width
will be set to the concrete width computed
concrete_height
will be set to the concrete height computed
sourcefn current_image(&self) -> Paintable
fn current_image(&self) -> Paintable
Gets an immutable paintable for the current contents displayed by @self.
This is useful when you want to retain the current state of an animation, for example to take a screenshot of a running animation.
If the @self is already immutable, it will return itself.
Returns
An immutable paintable for the current contents of @self
sourcefn flags(&self) -> PaintableFlags
fn flags(&self) -> PaintableFlags
Get flags for the paintable.
This is oftentimes useful for optimizations.
See PaintableFlags
for the flags and what they mean.
Returns
The PaintableFlags
for this paintable
sourcefn intrinsic_aspect_ratio(&self) -> f64
fn intrinsic_aspect_ratio(&self) -> f64
Gets the preferred aspect ratio the @self would like to be displayed at.
The aspect ratio is the width divided by the height, so a value of 0.5 means that the @self prefers to be displayed twice as high as it is wide. Consumers of this interface can use this to preserve aspect ratio when displaying the paintable.
This is a purely informational value and does not in any way limit the
values that may be passed to snapshot()
.
Usually when a @self returns nonzero values from
intrinsic_width()
and
intrinsic_height()
the aspect ratio
should conform to those values, though that is not required.
If the @self does not have a preferred aspect ratio, it returns 0. Negative values are never returned.
Returns
the intrinsic aspect ratio of @self or 0 if none.
sourcefn intrinsic_height(&self) -> i32
fn intrinsic_height(&self) -> i32
Gets the preferred height the @self would like to be displayed at.
Consumers of this interface can use this to reserve enough space to draw the paintable.
This is a purely informational value and does not in any way limit the
values that may be passed to snapshot()
.
If the @self does not have a preferred height, it returns 0. Negative values are never returned.
Returns
the intrinsic height of @self or 0 if none.
sourcefn intrinsic_width(&self) -> i32
fn intrinsic_width(&self) -> i32
Gets the preferred width the @self would like to be displayed at.
Consumers of this interface can use this to reserve enough space to draw the paintable.
This is a purely informational value and does not in any way limit the
values that may be passed to snapshot()
.
If the @self does not have a preferred width, it returns 0. Negative values are never returned.
Returns
the intrinsic width of @self or 0 if none.
sourcefn invalidate_contents(&self)
fn invalidate_contents(&self)
Called by implementations of Paintable
to invalidate their contents.
Unless the contents are invalidated, implementations must guarantee that
multiple calls of snapshot()
produce the same output.
This function will emit the invalidate-contents
signal.
If a @self reports the PaintableFlags::CONTENTS
flag,
it must not call this function.
sourcefn invalidate_size(&self)
fn invalidate_size(&self)
Called by implementations of Paintable
to invalidate their size.
As long as the size is not invalidated, @self must return the same values for its intrinsic width, height and aspect ratio.
This function will emit the invalidate-size
signal.
If a @self reports the PaintableFlags::SIZE
flag,
it must not call this function.
sourcefn snapshot(&self, snapshot: &impl IsA<Snapshot>, width: f64, height: f64)
fn snapshot(&self, snapshot: &impl IsA<Snapshot>, width: f64, height: f64)
Snapshots the given paintable with the given @width and @height.
The paintable is drawn at the current (0,0) offset of the @snapshot. If @width and @height are not larger than zero, this function will do nothing.
snapshot
a Snapshot
to snapshot to
width
width to snapshot in
height
height to snapshot in
sourcefn connect_invalidate_contents<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_invalidate_contents<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Emitted when the contents of the @paintable change.
Examples for such an event would be videos changing to the next frame or the icon theme for an icon changing.
sourcefn connect_invalidate_size<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_invalidate_size<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Emitted when the intrinsic size of the @paintable changes.
This means the values reported by at least one of
intrinsic_width()
,
intrinsic_height()
or
intrinsic_aspect_ratio()
has changed.
Examples for such an event would be a paintable displaying the contents of a toplevel surface being resized.