Paintable

open class Paintable : PaintableProtocol

The Paintable type acts as an owner of an underlying GdkPaintable instance. It provides the methods that can operate on this data type through PaintableProtocol conformance. Use Paintable as a strong reference or owner of a GdkPaintable instance.

GdkPaintable is a simple interface used by GTK to represent content that can be painted.

The content of a GdkPaintable 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 GdkPaintable can be snapshot at any time and size using [methodGdk.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 GdkPaintable and don’t know what to do, it is suggested that you scale your paintable ignoring any potential aspect ratio.

The contents that a GdkPaintable produces may depend on the [classGdkSnapshot] passed to it. For example, paintables may decide to use more detailed images on higher resolution screens or when OpenGL is available. A GdkPaintable will however always produce the same output for the same snapshot.

A GdkPaintable may change its contents, meaning that it will now produce a different output with the same snapshot. Once that happens, it will call [methodGdk.Paintable.invalidate_contents] which will emit the [signalGdkPaintable::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 [methodGdk.Paintable.get_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 [methodGdk.Paintable.invalidate_size] which will emit the [signalGdkPaintable::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: [methodGdk.Paintable.invalidate_contents], [methodGdk.Paintable.invalidate_size], [funcGdk.Paintable.new_empty].

  • ptr
    Untyped pointer to the underlying `GdkPaintable` instance.
    

    For type-safe access, use the generated, typed pointer paintable_ptr property instead.

    Declaration

    Swift

    public let ptr: UnsafeMutableRawPointer!
  • Designated initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GdkPaintable>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GdkPaintable>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GdkPaintable>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GdkPaintable>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. GdkPaintable does not allow reference counting, so despite the name no actual retaining will occur. i.e., ownership is transferred to the Paintable instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GdkPaintable>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements PaintableProtocol GdkPaintable does not allow reference counting.

    Declaration

    Swift

    @inlinable
    public init<T>(_ other: T) where T : PaintableProtocol

    Parameters

    other

    an instance of a related type that implements PaintableProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init(raw p: UnsafeRawPointer)

    Parameters

    p

    raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init(retainingRaw raw: UnsafeRawPointer)
  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable raw pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable raw pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to PaintableProtocol.

    Declaration

    Swift

    @inlinable
    public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

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

    This is often useful for implementing the GdkPaintableInterface.get_current_image() virtual function when the paintable is in an incomplete state (like a [classGtk.MediaStream] before receiving the first frame).

    Declaration

    Swift

    @inlinable
    public static func new(empty intrinsicWidth: Int, intrinsicHeight: Int) -> Paintable!