gtk4/auto/
symbolic_paintable.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// [`SymbolicPaintable`][crate::SymbolicPaintable] is an interface that support symbolic colors in
10    /// paintables.
11    ///
12    /// [`gdk::Paintable`][crate::gdk::Paintable]s implementing the interface will have the
13    /// `vfunc::Gtk::SymbolicPaintable::snapshot_symbolic` function called and
14    /// have the colors for drawing symbolic icons passed. At least 4 colors are guaranteed
15    /// to be passed every time.
16    ///
17    /// These 4 colors are the foreground color, and the colors to use for errors, warnings
18    /// and success information in that order.
19    ///
20    /// More colors may be added in the future.
21    ///
22    /// # Implements
23    ///
24    /// [`SymbolicPaintableExt`][trait@crate::prelude::SymbolicPaintableExt], [`trait@gdk::prelude::PaintableExt`]
25    #[doc(alias = "GtkSymbolicPaintable")]
26    pub struct SymbolicPaintable(Interface<ffi::GtkSymbolicPaintable, ffi::GtkSymbolicPaintableInterface>) @requires gdk::Paintable;
27
28    match fn {
29        type_ => || ffi::gtk_symbolic_paintable_get_type(),
30    }
31}
32
33impl SymbolicPaintable {
34    pub const NONE: Option<&'static SymbolicPaintable> = None;
35}
36
37mod sealed {
38    pub trait Sealed {}
39    impl<T: super::IsA<super::SymbolicPaintable>> Sealed for T {}
40}
41
42/// Trait containing all [`struct@SymbolicPaintable`] methods.
43///
44/// # Implementors
45///
46/// [`IconPaintable`][struct@crate::IconPaintable], [`SymbolicPaintable`][struct@crate::SymbolicPaintable]
47pub trait SymbolicPaintableExt: IsA<SymbolicPaintable> + sealed::Sealed + 'static {
48    /// Snapshots the paintable with the given colors.
49    ///
50    /// If less than 4 colors are provided, GTK will pad the array with default
51    /// colors.
52    /// ## `snapshot`
53    /// a [`gdk::Snapshot`][crate::gdk::Snapshot] to snapshot to
54    /// ## `width`
55    /// width to snapshot in
56    /// ## `height`
57    /// height to snapshot in
58    /// ## `colors`
59    /// a pointer to an array of colors
60    #[doc(alias = "gtk_symbolic_paintable_snapshot_symbolic")]
61    fn snapshot_symbolic(
62        &self,
63        snapshot: &impl IsA<gdk::Snapshot>,
64        width: f64,
65        height: f64,
66        colors: &[gdk::RGBA],
67    ) {
68        let n_colors = colors.len() as _;
69        unsafe {
70            ffi::gtk_symbolic_paintable_snapshot_symbolic(
71                self.as_ref().to_glib_none().0,
72                snapshot.as_ref().to_glib_none().0,
73                width,
74                height,
75                colors.to_glib_none().0,
76                n_colors,
77            );
78        }
79    }
80}
81
82impl<O: IsA<SymbolicPaintable>> SymbolicPaintableExt for O {}