Paintable

gdk.paintable.Paintable is a simple interface used by GTK to represent content that can be painted.

The content of a gdk.paintable.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.Paintable can be snapshot at any time and size using gdk.paintable.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.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.Paintable produces may depend on the gdk.snapshot.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.Paintable will however always produce the same output for the same snapshot.

A gdk.paintable.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.Paintable.invalidateContents 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.types.PaintableFlags.Contents flag. If a consumer cannot deal with changing contents, it may call gdk.paintable.Paintable.getCurrentImage 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.Paintable.invalidateSize 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.types.PaintableFlags.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.Paintable.invalidateContents, gdk.paintable.Paintable.invalidateSize, gdk.paintable.Paintable.newEmpty.

Members

Functions

computeConcreteSize
void computeConcreteSize(double specifiedWidth, double specifiedHeight, double defaultWidth, double defaultHeight, double concreteWidth, double concreteHeight)

Compute a concrete size for the gdk.paintable.Paintable.

connectInvalidateContents
ulong connectInvalidateContents(T callback, Flag!"After" after)

Connect to InvalidateContents signal.

connectInvalidateSize
ulong connectInvalidateSize(T callback, Flag!"After" after)

Connect to InvalidateSize signal.

getCurrentImage
gdk.paintable.Paintable getCurrentImage()

Gets an immutable paintable for the current contents displayed by paintable.

getFlags
gdk.types.PaintableFlags getFlags()

Get flags for the paintable.

getIntrinsicAspectRatio
double getIntrinsicAspectRatio()

Gets the preferred aspect ratio the paintable would like to be displayed at.

getIntrinsicHeight
int getIntrinsicHeight()

Gets the preferred height the paintable would like to be displayed at.

getIntrinsicWidth
int getIntrinsicWidth()

Gets the preferred width the paintable would like to be displayed at.

invalidateContents
void invalidateContents()

Called by implementations of gdk.paintable.Paintable to invalidate their contents.

invalidateSize
void invalidateSize()

Called by implementations of gdk.paintable.Paintable to invalidate their size.

snapshot
void snapshot(gdk.snapshot.Snapshot snapshot, double width, double height)

Snapshots the given paintable with the given width and height.

Static functions

newEmpty
gdk.paintable.Paintable newEmpty(int intrinsicWidth, int intrinsicHeight)

Returns a paintable that has the given intrinsic size and draws nothing.