module Gdk::Paintable
Overview
Gdk::Paintable
is a simple interface used by GTK to represent content that
can be painted.
The content of a Gdk::Paintable
can be painted anywhere at any size
without requiring any sort of layout. The interface is inspired by
similar concepts elsewhere, such as
ClutterContent,
HTML/CSS Paint Sources,
or SVG Paint Servers.
A Gdk::Paintable
can be snapshot at any time and size using
Gdk::Paintable#snapshot
. How the paintable interprets that size and
if it scales or centers itself into the given rectangle is implementation
defined, though if you are implementing a Gdk::Paintable
and don't know what
to do, it is suggested that you scale your paintable ignoring any potential
aspect ratio.
The contents that a Gdk::Paintable
produces may depend on the #Gdk::Snapshot
passed to it. For example, paintables may decide to use more detailed images
on higher resolution screens or when OpenGL is available. A Gdk::Paintable
will however always produce the same output for the same snapshot.
A Gdk::Paintable
may change its contents, meaning that it will now produce
a different output with the same snapshot. Once that happens, it will call
Gdk::Paintable#invalidate_contents
which will emit the
[signal@Gdk::Paintable::invalidate-contents] signal. If a paintable is known
to never change its contents, it will set the %GDK_PAINTABLE_STATIC_CONTENTS
flag. If a consumer cannot deal with changing contents, it may call
Gdk::Paintable#current_image
which will return a static
paintable and use that.
A paintable can report an intrinsic (or preferred) size or aspect ratio it
wishes to be rendered at, though it doesn't have to. Consumers of the interface
can use this information to layout thepaintable appropriately. Just like the
contents, the size of a paintable can change. A paintable will indicate this
by calling Gdk::Paintable#invalidate_size
which will emit the
[signal@Gdk::Paintable::invalidate-size] signal. And just like for contents,
if a paintable is known to never change its size, it will set the
%GDK_PAINTABLE_STATIC_SIZE flag.
Besides API for applications, there are some functions that are only
useful for implementing subclasses and should not be used by applications:
Gdk::Paintable#invalidate_contents
,
Gdk::Paintable#invalidate_size
,
Gdk::Paintable#new_empty
.
Direct including types
- Gdk::GLTexture
- Gdk::MemoryTexture
- Gdk::Texture
- Gtk::IconPaintable
- Gtk::MediaFile
- Gtk::MediaStream
- Gtk::WidgetPaintable
Defined in:
lib/gi-crystal/src/auto/gdk-4.0/paintable.crConstructors
-
.cast(obj : GObject::Object) : self
Cast a
GObject::Object
toself
, throws aTypeCastError
if the cast can't be made.
Class Method Summary
- .cast?(obj : GObject::Object) : self | Nil
- .g_type : UInt64
- .new_empty(intrinsic_width : Int32, intrinsic_height : Int32) : Gdk::Paintable
Instance Method Summary
- #compute_concrete_size(specified_width : Float64, specified_height : Float64, default_width : Float64, default_height : Float64, concrete_width : Float64, concrete_height : Float64) : Nil
- #current_image : Gdk::Paintable
- #flags : Gdk::PaintableFlags
- #intrinsic_aspect_ratio : Float64
- #intrinsic_height : Int32
- #intrinsic_width : Int32
- #invalidate_contents : Nil
- #invalidate_contents_signal
- #invalidate_size : Nil
- #invalidate_size_signal
- #snapshot(snapshot : Gdk::Snapshot, width : Float64, height : Float64) : Nil
- #to_unsafe
Constructor Detail
Cast a GObject::Object
to self
, throws a TypeCastError
if the cast can't be made.