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 /// An interface that supports symbolic colors in paintables.
10 ///
11 /// [`gdk::Paintable`][crate::gdk::Paintable]s implementing the interface will have the
12 /// `vfunc::Gtk::SymbolicPaintable::snapshot_symbolic` function called and
13 /// have the colors for drawing symbolic icons passed. At least 5 colors
14 /// are guaranteed to be passed every time. These 5 colors are the
15 /// foreground color, and the colors to use for errors, warnings
16 /// and success information in that order, followed by the system
17 /// accent color.
18 ///
19 /// The system accent color has been added in GTK 4.22.
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
37/// Trait containing all [`struct@SymbolicPaintable`] methods.
38///
39/// # Implementors
40///
41/// [`IconPaintable`][struct@crate::IconPaintable], [`Svg`][struct@crate::Svg], [`SymbolicPaintable`][struct@crate::SymbolicPaintable]
42pub trait SymbolicPaintableExt: IsA<SymbolicPaintable> + 'static {
43 /// Snapshots the paintable with the given colors.
44 ///
45 /// If less than 5 colors are provided, GTK will pad the array with default
46 /// colors.
47 /// ## `snapshot`
48 /// a [`gdk::Snapshot`][crate::gdk::Snapshot] to snapshot to
49 /// ## `width`
50 /// width to snapshot in
51 /// ## `height`
52 /// height to snapshot in
53 /// ## `colors`
54 /// a pointer to an array of colors
55 #[doc(alias = "gtk_symbolic_paintable_snapshot_symbolic")]
56 fn snapshot_symbolic(
57 &self,
58 snapshot: &impl IsA<gdk::Snapshot>,
59 width: f64,
60 height: f64,
61 colors: &[gdk::RGBA],
62 ) {
63 let n_colors = colors.len() as _;
64 unsafe {
65 ffi::gtk_symbolic_paintable_snapshot_symbolic(
66 self.as_ref().to_glib_none().0,
67 snapshot.as_ref().to_glib_none().0,
68 width,
69 height,
70 colors.to_glib_none().0,
71 n_colors,
72 );
73 }
74 }
75
76 /// Snapshots the paintable with the given colors and weight.
77 ///
78 /// If less than 5 colors are provided, GTK will pad the array with default
79 /// colors.
80 /// ## `snapshot`
81 /// a [`gdk::Snapshot`][crate::gdk::Snapshot] to snapshot to
82 /// ## `width`
83 /// width to snapshot in
84 /// ## `height`
85 /// height to snapshot in
86 /// ## `colors`
87 /// a pointer to an array of colors
88 /// ## `weight`
89 /// The font weight to use (from 1 to 1000, with default 400)
90 #[cfg(feature = "v4_22")]
91 #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
92 #[doc(alias = "gtk_symbolic_paintable_snapshot_with_weight")]
93 fn snapshot_with_weight(
94 &self,
95 snapshot: &impl IsA<gdk::Snapshot>,
96 width: f64,
97 height: f64,
98 colors: &[gdk::RGBA],
99 weight: f64,
100 ) {
101 let n_colors = colors.len() as _;
102 unsafe {
103 ffi::gtk_symbolic_paintable_snapshot_with_weight(
104 self.as_ref().to_glib_none().0,
105 snapshot.as_ref().to_glib_none().0,
106 width,
107 height,
108 colors.to_glib_none().0,
109 n_colors,
110 weight,
111 );
112 }
113 }
114}
115
116impl<O: IsA<SymbolicPaintable>> SymbolicPaintableExt for O {}