gtkmm 4.16.0
|
An interface for a paintable region. More...
#include <gdkmm/paintable.h>
Public Types | |
enum class | Flags { Flags::STATIC_SIZE = 1 << 0 , Flags::STATIC_CONTENTS = 1 << 1 } |
Flags about a paintable object. More... | |
Public Member Functions | |
Paintable (Paintable &&src) noexcept | |
Paintable & | operator= (Paintable &&src) noexcept |
~Paintable () noexcept override | |
GdkPaintable * | gobj () |
Provides access to the underlying C GObject. | |
const GdkPaintable * | gobj () const |
Provides access to the underlying C GObject. | |
void | snapshot (const Glib::RefPtr< Gdk::Snapshot > & snapshot, double width, double height) |
Snapshots the given paintable with the given width and height. | |
Glib::RefPtr< const Paintable > | get_current_image () const |
Gets an immutable paintable for the current contents displayed by paintable. | |
Flags | get_flags () const |
Get flags for the paintable. | |
int | get_intrinsic_width () const |
Gets the preferred width the paintable would like to be displayed at. | |
int | get_intrinsic_height () const |
Gets the preferred height the paintable would like to be displayed at. | |
double | get_intrinsic_aspect_ratio () const |
Gets the preferred aspect ratio the paintable would like to be displayed at. | |
void | compute_concrete_size (double specified_width, double specified_height, double default_width, double default_height, double &concrete_width, double &concrete_height) const |
Compute a concrete size for the Gdk::Paintable . | |
void | invalidate_contents () |
Called by implementations of Gdk::Paintable to invalidate their contents. | |
void | invalidate_size () |
Called by implementations of Gdk::Paintable to invalidate their size. | |
Glib::SignalProxy< void()> | signal_invalidate_contents () |
Glib::SignalProxy< void()> | signal_invalidate_size () |
Static Public Member Functions | |
static void | add_interface (GType gtype_implementer) |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Protected Member Functions | |
Paintable () | |
You should derive from this class to use it. | |
virtual void | snapshot_vfunc (const Glib::RefPtr< Gdk::Snapshot > &snapshot, double width, double height) |
virtual Glib::RefPtr< Paintable > | get_current_image_vfunc () const |
virtual Flags | get_flags_vfunc () const |
virtual int | get_intrinsic_width_vfunc () const |
virtual int | get_intrinsic_height_vfunc () const |
virtual double | get_intrinsic_aspect_ratio_vfunc () const |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gdk::Paintable > | wrap (GdkPaintable *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
An interface for a paintable region.
Gdk::Paintable is a simple interface used by GDK and GTK to represent objects that 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 Paintable can be snapshot at any time and size using 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 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 Paintable produces may depend on the Snapshot passed to it. For example, paintables may decide to use more detailed images on higher resolution screens or when OpenGL is available. A Paintable will however always produce the same output for the same snapshot.
A Paintable may change its contents, meaning that it will now produce a different output with the same snpashot. Once that happens, it will call invalidate_contents() which will emit the signal_invalidate_contents() signal.
If a paintable is known to never change its contents, it will set the Flags::STATIC_CONTENTS flag. If a consumer cannot deal with changing contents, it may call 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 the paintable appropriately. Just like the contents, the size of a paintable can change. A paintable will indicate this by calling invalidate_size() which will emit the signal_invalidate_size() signal. And just like for contents, if a paintable is known to never change its size, it will set the Flags::STATIC_SIZE flag.
|
protected |
You should derive from this class to use it.
|
noexcept |
|
overridenoexcept |
void Gdk::Paintable::compute_concrete_size | ( | double | specified_width, |
double | specified_height, | ||
double | default_width, | ||
double | default_height, | ||
double & | concrete_width, | ||
double & | concrete_height | ||
) | const |
Compute a concrete size for the Gdk::Paintable
.
Applies the sizing algorithm outlined in the CSS Image spec to the given paintable. 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 paintable could be drawn into or 0.0 if unknown. |
specified_height | The height paintable could be drawn into or 0.0 if unknown. |
default_width | The width paintable would be drawn into if no other constraints were given. |
default_height | The height paintable would be drawn into if no other constraints were given. |
concrete_width | Will be set to the concrete width computed. |
concrete_height | Will be set to the concrete height computed. |
Gets an immutable paintable for the current contents displayed by paintable.
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 paintable is already immutable, it will return itself.
|
protectedvirtual |
Flags Gdk::Paintable::get_flags | ( | ) | const |
Get flags for the paintable.
This is oftentimes useful for optimizations.
See Gdk::PaintableFlags for the flags and what they mean.
Gdk::PaintableFlags
for this paintable. double Gdk::Paintable::get_intrinsic_aspect_ratio | ( | ) | const |
Gets the preferred aspect ratio the paintable 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 paintable 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 paintable returns nonzero values from get_intrinsic_width() and get_intrinsic_height() the aspect ratio should conform to those values, though that is not required.
If the paintable does not have a preferred aspect ratio, it returns 0. Negative values are never returned.
int Gdk::Paintable::get_intrinsic_height | ( | ) | const |
Gets the preferred height the paintable 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 paintable does not have a preferred height, it returns 0. Negative values are never returned.
|
protectedvirtual |
int Gdk::Paintable::get_intrinsic_width | ( | ) | const |
Gets the preferred width the paintable 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 paintable does not have a preferred width, it returns 0. Negative values are never returned.
|
protectedvirtual |
|
static |
Get the GType for this class, for use with the underlying GObject type system.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
void Gdk::Paintable::invalidate_contents | ( | ) |
Called by implementations of Gdk::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 signal_invalidate_contents() signal.
If a paintable reports the Gdk::Paintable::Flags::STATIC_CONTENTS flag, it must not call this function.
void Gdk::Paintable::invalidate_size | ( | ) |
Called by implementations of Gdk::Paintable
to invalidate their size.
As long as the size is not invalidated, paintable must return the same values for its intrinsic width, height and aspect ratio.
This function will emit the signal_invalidate_size() signal.
If a paintable reports the Gdk::Paintable::Flags::STATIC_SIZE flag, it must not call this function.
Glib::SignalProxy< void()> Gdk::Paintable::signal_invalidate_contents | ( | ) |
void on_my_invalidate_contents()
Flags: Run Last
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.
Glib::SignalProxy< void()> Gdk::Paintable::signal_invalidate_size | ( | ) |
void on_my_invalidate_size()
Flags: Run Last
Emitted when the intrinsic size of the paintable changes.
This means the values reported by at least one of Gdk::Paintable::get_intrinsic_width(), Gdk::Paintable::get_intrinsic_height() or Gdk::Paintable::get_intrinsic_aspect_ratio() has changed.
Examples for such an event would be a paintable displaying the contents of a toplevel surface being resized.
void Gdk::Paintable::snapshot | ( | const Glib::RefPtr< Gdk::Snapshot > & | snapshot, |
double | width, | ||
double | height | ||
) |
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 Gdk::Snapshot to snapshot to. |
width | Width to snapshot in. |
height | Height to snapshot in. |
|
protectedvirtual |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |