gsk4/auto/texture_scale_node.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, ScalingFilter};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// A render node for a [`gdk::Texture`][crate::gdk::Texture].
10 #[doc(alias = "GskTextureScaleNode")]
11 pub struct TextureScaleNode(Shared<ffi::GskTextureScaleNode>);
12
13 match fn {
14 ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
15 unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
16 }
17}
18
19impl StaticType for TextureScaleNode {
20 fn static_type() -> glib::Type {
21 unsafe { from_glib(ffi::gsk_texture_scale_node_get_type()) }
22 }
23}
24
25impl TextureScaleNode {
26 /// Creates a node that scales the texture to the size given by the
27 /// bounds using the filter and then places it at the bounds' position.
28 ///
29 /// Note that further scaling and other transformations which are
30 /// applied to the node will apply linear filtering to the resulting
31 /// texture, as usual.
32 ///
33 /// This node is intended for tight control over scaling applied
34 /// to a texture, such as in image editors and requires the
35 /// application to be aware of the whole render tree as further
36 /// transforms may be applied that conflict with the desired effect
37 /// of this node.
38 /// ## `texture`
39 /// the texture to scale
40 /// ## `bounds`
41 /// the size of the texture to scale to
42 /// ## `filter`
43 /// how to scale the texture
44 ///
45 /// # Returns
46 ///
47 /// A new [`RenderNode`][crate::RenderNode]
48 #[doc(alias = "gsk_texture_scale_node_new")]
49 pub fn new(
50 texture: &impl IsA<gdk::Texture>,
51 bounds: &graphene::Rect,
52 filter: ScalingFilter,
53 ) -> TextureScaleNode {
54 assert_initialized_main_thread!();
55 unsafe {
56 from_glib_full(ffi::gsk_texture_scale_node_new(
57 texture.as_ref().to_glib_none().0,
58 bounds.to_glib_none().0,
59 filter.into_glib(),
60 ))
61 }
62 }
63
64 /// Retrieves the [`ScalingFilter`][crate::ScalingFilter] used when creating this [`RenderNode`][crate::RenderNode].
65 ///
66 /// # Returns
67 ///
68 /// the [`ScalingFilter`][crate::ScalingFilter]
69 #[doc(alias = "gsk_texture_scale_node_get_filter")]
70 #[doc(alias = "get_filter")]
71 pub fn filter(&self) -> ScalingFilter {
72 unsafe {
73 from_glib(ffi::gsk_texture_scale_node_get_filter(
74 self.to_glib_none().0,
75 ))
76 }
77 }
78
79 /// Retrieves the [`gdk::Texture`][crate::gdk::Texture] used when creating this [`RenderNode`][crate::RenderNode].
80 ///
81 /// # Returns
82 ///
83 /// the [`gdk::Texture`][crate::gdk::Texture]
84 #[doc(alias = "gsk_texture_scale_node_get_texture")]
85 #[doc(alias = "get_texture")]
86 pub fn texture(&self) -> gdk::Texture {
87 unsafe {
88 from_glib_none(ffi::gsk_texture_scale_node_get_texture(
89 self.to_glib_none().0,
90 ))
91 }
92 }
93}