1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::StyleContext;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
/// [`Snapshot`][crate::Snapshot] assists in creating `GskRenderNodes` for widgets.
///
/// It functions in a similar way to a cairo context, and maintains a stack
/// of render nodes and their associated transformations.
///
/// The node at the top of the stack is the the one that gtk_snapshot_append_…
/// functions operate on. Use the gtk_snapshot_push_… functions and
/// [`pop()`][Self::pop()] to change the current node.
///
/// The typical way to obtain a [`Snapshot`][crate::Snapshot] object is as an argument to
/// the `vfunc::Gtk::Widget::snapshot` vfunc. If you need to create your own
/// [`Snapshot`][crate::Snapshot], use [``new()``][`Self::new()`].
///
/// # Implements
///
/// [`trait@gdk::prelude::SnapshotExt`], [`trait@glib::ObjectExt`]
#[doc(alias = "GtkSnapshot")]
pub struct Snapshot(Object<ffi::GtkSnapshot, ffi::GtkSnapshotClass>) @extends gdk::Snapshot;
match fn {
type_ => || ffi::gtk_snapshot_get_type(),
}
}
impl Snapshot {
/// Creates a new [`Snapshot`][crate::Snapshot].
///
/// # Returns
///
/// a newly-allocated [`Snapshot`][crate::Snapshot]
#[doc(alias = "gtk_snapshot_new")]
pub fn new() -> Snapshot {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gtk_snapshot_new()) }
}
/// Creates a new [`gsk::CairoNode`][crate::gsk::CairoNode] and appends it to the current
/// render node of `self`, without changing the current node.
/// ## `bounds`
/// the bounds for the new node
///
/// # Returns
///
/// a `cairo_t` suitable for drawing the contents of
/// the newly created render node
#[doc(alias = "gtk_snapshot_append_cairo")]
pub fn append_cairo(&self, bounds: &graphene::Rect) -> Option<cairo::Context> {
unsafe {
from_glib_full(ffi::gtk_snapshot_append_cairo(
self.to_glib_none().0,
bounds.to_glib_none().0,
))
}
}
/// Creates a new render node drawing the `color` into the
/// given `bounds` and appends it to the current render node
/// of `self`.
///
/// You should try to avoid calling this function if
/// `color` is transparent.
/// ## `color`
/// the [`gdk::RGBA`][crate::gdk::RGBA] to draw
/// ## `bounds`
/// the bounds for the new node
#[doc(alias = "gtk_snapshot_append_color")]
pub fn append_color(&self, color: &gdk::RGBA, bounds: &graphene::Rect) {
unsafe {
ffi::gtk_snapshot_append_color(
self.to_glib_none().0,
color.to_glib_none().0,
bounds.to_glib_none().0,
);
}
}
/// Appends an inset shadow into the box given by `outline`.
/// ## `outline`
/// outline of the region surrounded by shadow
/// ## `color`
/// color of the shadow
/// ## `dx`
/// horizontal offset of shadow
/// ## `dy`
/// vertical offset of shadow
/// ## `spread`
/// how far the shadow spreads towards the inside
/// ## `blur_radius`
/// how much blur to apply to the shadow
#[doc(alias = "gtk_snapshot_append_inset_shadow")]
pub fn append_inset_shadow(
&self,
outline: &gsk::RoundedRect,
color: &gdk::RGBA,
dx: f32,
dy: f32,
spread: f32,
blur_radius: f32,
) {
unsafe {
ffi::gtk_snapshot_append_inset_shadow(
self.to_glib_none().0,
outline.to_glib_none().0,
color.to_glib_none().0,
dx,
dy,
spread,
blur_radius,
);
}
}
#[doc(alias = "gtk_snapshot_append_layout")]
pub fn append_layout(&self, layout: &pango::Layout, color: &gdk::RGBA) {
unsafe {
ffi::gtk_snapshot_append_layout(
self.to_glib_none().0,
layout.to_glib_none().0,
color.to_glib_none().0,
);
}
}
/// Appends an outset shadow node around the box given by `outline`.
/// ## `outline`
/// outline of the region surrounded by shadow
/// ## `color`
/// color of the shadow
/// ## `dx`
/// horizontal offset of shadow
/// ## `dy`
/// vertical offset of shadow
/// ## `spread`
/// how far the shadow spreads towards the outside
/// ## `blur_radius`
/// how much blur to apply to the shadow
#[doc(alias = "gtk_snapshot_append_outset_shadow")]
pub fn append_outset_shadow(
&self,
outline: &gsk::RoundedRect,
color: &gdk::RGBA,
dx: f32,
dy: f32,
spread: f32,
blur_radius: f32,
) {
unsafe {
ffi::gtk_snapshot_append_outset_shadow(
self.to_glib_none().0,
outline.to_glib_none().0,
color.to_glib_none().0,
dx,
dy,
spread,
blur_radius,
);
}
}
/// Creates a new render node drawing the `texture`
/// into the given `bounds` and appends it to the
/// current render node of `self`.
/// ## `texture`
/// the [`gdk::Texture`][crate::gdk::Texture] to render
/// ## `bounds`
/// the bounds for the new node
#[doc(alias = "gtk_snapshot_append_texture")]
pub fn append_texture<P: IsA<gdk::Texture>>(&self, texture: &P, bounds: &graphene::Rect) {
unsafe {
ffi::gtk_snapshot_append_texture(
self.to_glib_none().0,
texture.as_ref().to_glib_none().0,
bounds.to_glib_none().0,
);
}
}
/// Returns the node that was constructed by `self`
/// and frees `self`.
///
/// # Returns
///
/// a newly-created [`gsk::RenderNode`][crate::gsk::RenderNode]
#[doc(alias = "gtk_snapshot_free_to_node")]
pub fn free_to_node(&self) -> Option<gsk::RenderNode> {
unsafe { from_glib_full(ffi::gtk_snapshot_free_to_node(self.to_glib_full())) }
}
/// Returns a paintable for the node that was
/// constructed by `self` and frees `self`.
/// ## `size`
/// The size of the resulting paintable
/// or [`None`] to use the bounds of the snapshot
///
/// # Returns
///
/// a newly-created [`gdk::Paintable`][crate::gdk::Paintable]
#[doc(alias = "gtk_snapshot_free_to_paintable")]
pub fn free_to_paintable(&self, size: Option<&graphene::Size>) -> Option<gdk::Paintable> {
unsafe {
from_glib_full(ffi::gtk_snapshot_free_to_paintable(
self.to_glib_full(),
size.to_glib_none().0,
))
}
}
/// Removes the top element from the stack of render nodes and
/// adds it to the nearest [`gsk::GLShaderNode`][crate::gsk::GLShaderNode] below it.
///
/// This must be called the same number of times as the number
/// of textures is needed for the shader in
/// [``push_gl_shader()``][`Self::push_gl_shader()`].
#[doc(alias = "gtk_snapshot_gl_shader_pop_texture")]
pub fn gl_shader_pop_texture(&self) {
unsafe {
ffi::gtk_snapshot_gl_shader_pop_texture(self.to_glib_none().0);
}
}
/// Applies a perspective projection transform.
///
/// See [`gsk::`Transform::perspective()``][crate::gsk::`Transform::perspective()`] for a discussion on the details.
/// ## `depth`
/// distance of the z=0 plane
#[doc(alias = "gtk_snapshot_perspective")]
pub fn perspective(&self, depth: f32) {
unsafe {
ffi::gtk_snapshot_perspective(self.to_glib_none().0, depth);
}
}
/// Removes the top element from the stack of render nodes,
/// and appends it to the node underneath it.
#[doc(alias = "gtk_snapshot_pop")]
pub fn pop(&self) {
unsafe {
ffi::gtk_snapshot_pop(self.to_glib_none().0);
}
}
/// Blends together two images with the given blend mode.
///
/// Until the first call to [``pop()``][`Self::pop()`], the
/// bottom image for the blend operation will be recorded.
/// After that call, the top image to be blended will be
/// recorded until the second call to [``pop()``][`Self::pop()`].
///
/// Calling this function requires two subsequent calls
/// to [``pop()``][`Self::pop()`].
/// ## `blend_mode`
/// blend mode to use
#[doc(alias = "gtk_snapshot_push_blend")]
pub fn push_blend(&self, blend_mode: gsk::BlendMode) {
unsafe {
ffi::gtk_snapshot_push_blend(self.to_glib_none().0, blend_mode.into_glib());
}
}
/// Blurs an image.
///
/// The image is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `radius`
/// the blur radius to use
#[doc(alias = "gtk_snapshot_push_blur")]
pub fn push_blur(&self, radius: f64) {
unsafe {
ffi::gtk_snapshot_push_blur(self.to_glib_none().0, radius);
}
}
/// Clips an image to a rectangle.
///
/// The image is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `bounds`
/// the rectangle to clip to
#[doc(alias = "gtk_snapshot_push_clip")]
pub fn push_clip(&self, bounds: &graphene::Rect) {
unsafe {
ffi::gtk_snapshot_push_clip(self.to_glib_none().0, bounds.to_glib_none().0);
}
}
/// Modifies the colors of an image by applying an affine transformation
/// in RGB space.
///
/// The image is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `color_matrix`
/// the color matrix to use
/// ## `color_offset`
/// the color offset to use
#[doc(alias = "gtk_snapshot_push_color_matrix")]
pub fn push_color_matrix(
&self,
color_matrix: &graphene::Matrix,
color_offset: &graphene::Vec4,
) {
unsafe {
ffi::gtk_snapshot_push_color_matrix(
self.to_glib_none().0,
color_matrix.to_glib_none().0,
color_offset.to_glib_none().0,
);
}
}
/// Snapshots a cross-fade operation between two images with the
/// given `progress`.
///
/// Until the first call to [``pop()``][`Self::pop()`], the start image
/// will be snapshot. After that call, the end image will be recorded
/// until the second call to [``pop()``][`Self::pop()`].
///
/// Calling this function requires two subsequent calls
/// to [``pop()``][`Self::pop()`].
/// ## `progress`
/// progress between 0.0 and 1.0
#[doc(alias = "gtk_snapshot_push_cross_fade")]
pub fn push_cross_fade(&self, progress: f64) {
unsafe {
ffi::gtk_snapshot_push_cross_fade(self.to_glib_none().0, progress);
}
}
/// Push a [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
///
/// The node uses the given [`gsk::GLShader`][crate::gsk::GLShader] and uniform values
/// Additionally this takes a list of `n_children` other nodes
/// which will be passed to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
///
/// The `take_args` argument is a block of data to use for uniform
/// arguments, as per types and offsets defined by the `shader`.
/// Normally this is generated by `Gsk::`GLShader::format_args()``
/// or `Gsk::ShaderArgsBuilder`.
///
/// The snapshotter takes ownership of `take_args`, so the caller should
/// not free it after this.
///
/// If the renderer doesn't support GL shaders, or if there is any
/// problem when compiling the shader, then the node will draw pink.
/// You should use [``GLShader::compile()``][crate::gsk::`GLShader::compile()`] to ensure the `shader`
/// will work for the renderer before using it.
///
/// If the shader requires textures (see [``GLShader::n_textures()``][crate::gsk::`GLShader::n_textures()`]),
/// then it is expected that you call [``gl_shader_pop_texture()``][`Self::gl_shader_pop_texture()`]
/// the number of times that are required. Each of these calls will generate
/// a node that is added as a child to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode], which in turn
/// will render these offscreen and pass as a texture to the shader.
///
/// Once all textures (if any) are pop:ed, you must call the regular
/// [``pop()``][`Self::pop()`].
///
/// If you want to use pre-existing textures as input to the shader rather
/// than rendering new ones, use [``append_texture()``][`Self::append_texture()`] to
/// push a texture node. These will be used directly rather than being
/// re-rendered.
///
/// For details on how to write shaders, see [`gsk::GLShader`][crate::gsk::GLShader].
/// ## `shader`
/// The code to run
/// ## `bounds`
/// the rectangle to render into
/// ## `take_args`
/// Data block with arguments for the shader.
#[doc(alias = "gtk_snapshot_push_gl_shader")]
pub fn push_gl_shader(
&self,
shader: &gsk::GLShader,
bounds: &graphene::Rect,
take_args: &glib::Bytes,
) {
unsafe {
ffi::gtk_snapshot_push_gl_shader(
self.to_glib_none().0,
shader.to_glib_none().0,
bounds.to_glib_none().0,
take_args.to_glib_full(),
);
}
}
/// Modifies the opacity of an image.
///
/// The image is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `opacity`
/// the opacity to use
#[doc(alias = "gtk_snapshot_push_opacity")]
pub fn push_opacity(&self, opacity: f64) {
unsafe {
ffi::gtk_snapshot_push_opacity(self.to_glib_none().0, opacity);
}
}
/// Creates a node that repeats the child node.
///
/// The child is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `bounds`
/// the bounds within which to repeat
/// ## `child_bounds`
/// the bounds of the child or [`None`]
/// to use the full size of the collected child node
#[doc(alias = "gtk_snapshot_push_repeat")]
pub fn push_repeat(&self, bounds: &graphene::Rect, child_bounds: Option<&graphene::Rect>) {
unsafe {
ffi::gtk_snapshot_push_repeat(
self.to_glib_none().0,
bounds.to_glib_none().0,
child_bounds.to_glib_none().0,
);
}
}
/// Clips an image to a rounded rectangle.
///
/// The image is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `bounds`
/// the rounded rectangle to clip to
#[doc(alias = "gtk_snapshot_push_rounded_clip")]
pub fn push_rounded_clip(&self, bounds: &gsk::RoundedRect) {
unsafe {
ffi::gtk_snapshot_push_rounded_clip(self.to_glib_none().0, bounds.to_glib_none().0);
}
}
/// Applies a shadow to an image.
///
/// The image is recorded until the next call to [``pop()``][`Self::pop()`].
/// ## `shadow`
/// the first shadow specification
/// ## `n_shadows`
/// number of shadow specifications
#[doc(alias = "gtk_snapshot_push_shadow")]
pub fn push_shadow(&self, shadow: &gsk::Shadow, n_shadows: usize) {
unsafe {
ffi::gtk_snapshot_push_shadow(
self.to_glib_none().0,
shadow.to_glib_none().0,
n_shadows,
);
}
}
/// Creates a render node for the CSS background according to `context`,
/// and appends it to the current node of `self`, without changing
/// the current node.
/// ## `context`
/// the [`StyleContext`][crate::StyleContext] to use
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `width`
/// rectangle width
/// ## `height`
/// rectangle height
#[doc(alias = "gtk_snapshot_render_background")]
pub fn render_background<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64,
) {
unsafe {
ffi::gtk_snapshot_render_background(
self.to_glib_none().0,
context.as_ref().to_glib_none().0,
x,
y,
width,
height,
);
}
}
/// Creates a render node for the focus outline according to `context`,
/// and appends it to the current node of `self`, without changing
/// the current node.
/// ## `context`
/// the [`StyleContext`][crate::StyleContext] to use
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `width`
/// rectangle width
/// ## `height`
/// rectangle height
#[doc(alias = "gtk_snapshot_render_focus")]
pub fn render_focus<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64,
) {
unsafe {
ffi::gtk_snapshot_render_focus(
self.to_glib_none().0,
context.as_ref().to_glib_none().0,
x,
y,
width,
height,
);
}
}
/// Creates a render node for the CSS border according to `context`,
/// and appends it to the current node of `self`, without changing
/// the current node.
/// ## `context`
/// the [`StyleContext`][crate::StyleContext] to use
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `width`
/// rectangle width
/// ## `height`
/// rectangle height
#[doc(alias = "gtk_snapshot_render_frame")]
pub fn render_frame<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64,
) {
unsafe {
ffi::gtk_snapshot_render_frame(
self.to_glib_none().0,
context.as_ref().to_glib_none().0,
x,
y,
width,
height,
);
}
}
/// Draws a text caret using `self` at the specified index of `layout`.
/// ## `context`
/// a [`StyleContext`][crate::StyleContext]
/// ## `x`
/// X origin
/// ## `y`
/// Y origin
/// ## `layout`
/// the [`pango::Layout`][crate::pango::Layout] of the text
/// ## `index`
/// the index in the [`pango::Layout`][crate::pango::Layout]
/// ## `direction`
/// the [`pango::Direction`][crate::pango::Direction] of the text
#[doc(alias = "gtk_snapshot_render_insertion_cursor")]
pub fn render_insertion_cursor<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
layout: &pango::Layout,
index: i32,
direction: pango::Direction,
) {
unsafe {
ffi::gtk_snapshot_render_insertion_cursor(
self.to_glib_none().0,
context.as_ref().to_glib_none().0,
x,
y,
layout.to_glib_none().0,
index,
direction.into_glib(),
);
}
}
/// Creates a render node for rendering `layout` according to the style
/// information in `context`, and appends it to the current node of `self`,
/// without changing the current node.
/// ## `context`
/// the [`StyleContext`][crate::StyleContext] to use
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `layout`
/// the [`pango::Layout`][crate::pango::Layout] to render
#[doc(alias = "gtk_snapshot_render_layout")]
pub fn render_layout<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
layout: &pango::Layout,
) {
unsafe {
ffi::gtk_snapshot_render_layout(
self.to_glib_none().0,
context.as_ref().to_glib_none().0,
x,
y,
layout.to_glib_none().0,
);
}
}
/// Restores `self` to the state saved by a preceding call to
/// [`save()`][Self::save()] and removes that state from the stack of
/// saved states.
#[doc(alias = "gtk_snapshot_restore")]
pub fn restore(&self) {
unsafe {
ffi::gtk_snapshot_restore(self.to_glib_none().0);
}
}
/// Rotates @`self`'s coordinate system by `angle` degrees in 2D space -
/// or in 3D speak, rotates around the Z axis.
///
/// To rotate around other axes, use [`gsk::`Transform::rotate_3d()``][crate::gsk::`Transform::rotate_3d()`].
/// ## `angle`
/// the rotation angle, in degrees (clockwise)
#[doc(alias = "gtk_snapshot_rotate")]
pub fn rotate(&self, angle: f32) {
unsafe {
ffi::gtk_snapshot_rotate(self.to_glib_none().0, angle);
}
}
/// Rotates `self`'s coordinate system by `angle` degrees around `axis`.
///
/// For a rotation in 2D space, use [`gsk::`Transform::rotate()``][crate::gsk::`Transform::rotate()`].
/// ## `angle`
/// the rotation angle, in degrees (clockwise)
/// ## `axis`
/// The rotation axis
#[doc(alias = "gtk_snapshot_rotate_3d")]
pub fn rotate_3d(&self, angle: f32, axis: &graphene::Vec3) {
unsafe {
ffi::gtk_snapshot_rotate_3d(self.to_glib_none().0, angle, axis.to_glib_none().0);
}
}
/// Makes a copy of the current state of `self` and saves it
/// on an internal stack.
///
/// When [``restore()``][`Self::restore()`] is called, `self` will
/// be restored to the saved state. Multiple calls to
/// [`save()`][Self::save()] and [`restore()`][Self::restore()] can be nested;
/// each call to [`restore()`][Self::restore()] restores the state from
/// the matching paired [`save()`][Self::save()].
///
/// It is necessary to clear all saved states with corresponding
/// calls to [`restore()`][Self::restore()].
#[doc(alias = "gtk_snapshot_save")]
pub fn save(&self) {
unsafe {
ffi::gtk_snapshot_save(self.to_glib_none().0);
}
}
/// Scales `self`'s coordinate system in 2-dimensional space by
/// the given factors.
///
/// Use [``scale_3d()``][`Self::scale_3d()`] to scale in all 3 dimensions.
/// ## `factor_x`
/// scaling factor on the X axis
/// ## `factor_y`
/// scaling factor on the Y axis
#[doc(alias = "gtk_snapshot_scale")]
pub fn scale(&self, factor_x: f32, factor_y: f32) {
unsafe {
ffi::gtk_snapshot_scale(self.to_glib_none().0, factor_x, factor_y);
}
}
/// Scales `self`'s coordinate system by the given factors.
/// ## `factor_x`
/// scaling factor on the X axis
/// ## `factor_y`
/// scaling factor on the Y axis
/// ## `factor_z`
/// scaling factor on the Z axis
#[doc(alias = "gtk_snapshot_scale_3d")]
pub fn scale_3d(&self, factor_x: f32, factor_y: f32, factor_z: f32) {
unsafe {
ffi::gtk_snapshot_scale_3d(self.to_glib_none().0, factor_x, factor_y, factor_z);
}
}
/// Returns the render node that was constructed
/// by `self`.
///
/// After calling this function, it is no longer possible to
/// add more nodes to `self`. The only function that should
/// be called after this is `g_object_unref()`.
///
/// # Returns
///
/// the constructed [`gsk::RenderNode`][crate::gsk::RenderNode]
#[doc(alias = "gtk_snapshot_to_node")]
pub fn to_node(&self) -> Option<gsk::RenderNode> {
unsafe { from_glib_full(ffi::gtk_snapshot_to_node(self.to_glib_none().0)) }
}
/// Returns a paintable encapsulating the render node
/// that was constructed by `self`.
///
/// After calling this function, it is no longer possible to
/// add more nodes to `self`. The only function that should
/// be called after this is `g_object_unref()`.
/// ## `size`
/// The size of the resulting paintable
/// or [`None`] to use the bounds of the snapshot
///
/// # Returns
///
/// a new [`gdk::Paintable`][crate::gdk::Paintable]
#[doc(alias = "gtk_snapshot_to_paintable")]
pub fn to_paintable(&self, size: Option<&graphene::Size>) -> Option<gdk::Paintable> {
unsafe {
from_glib_full(ffi::gtk_snapshot_to_paintable(
self.to_glib_none().0,
size.to_glib_none().0,
))
}
}
/// Transforms `self`'s coordinate system with the given `transform`.
/// ## `transform`
/// the transform to apply
#[doc(alias = "gtk_snapshot_transform")]
pub fn transform(&self, transform: Option<&gsk::Transform>) {
unsafe {
ffi::gtk_snapshot_transform(self.to_glib_none().0, transform.to_glib_none().0);
}
}
/// Transforms `self`'s coordinate system with the given `matrix`.
/// ## `matrix`
/// the matrix to multiply the transform with
#[doc(alias = "gtk_snapshot_transform_matrix")]
pub fn transform_matrix(&self, matrix: &graphene::Matrix) {
unsafe {
ffi::gtk_snapshot_transform_matrix(self.to_glib_none().0, matrix.to_glib_none().0);
}
}
/// Translates `self`'s coordinate system by `point` in 2-dimensional space.
/// ## `point`
/// the point to translate the snapshot by
#[doc(alias = "gtk_snapshot_translate")]
pub fn translate(&self, point: &graphene::Point) {
unsafe {
ffi::gtk_snapshot_translate(self.to_glib_none().0, point.to_glib_none().0);
}
}
/// Translates `self`'s coordinate system by `point`.
/// ## `point`
/// the point to translate the snapshot by
#[doc(alias = "gtk_snapshot_translate_3d")]
pub fn translate_3d(&self, point: &graphene::Point3D) {
unsafe {
ffi::gtk_snapshot_translate_3d(self.to_glib_none().0, point.to_glib_none().0);
}
}
}
impl Default for Snapshot {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for Snapshot {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Snapshot")
}
}