gtk4/auto/snapshot.rs
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 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#![allow(deprecated)]
use crate::{ffi, StyleContext};
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// [`Snapshot`][crate::Snapshot] assists in creating [`gsk::RenderNode`][crate::gsk::RenderNode]s 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 one that `gtk_snapshot_append_…()`
/// functions operate on. Use the `gtk_snapshot_push_…()` functions and
/// [`SnapshotExt::pop()`][crate::prelude::SnapshotExt::pop()] to change the current node.
///
/// The typical way to obtain a [`Snapshot`][crate::Snapshot] object is as an argument to
/// the [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()] vfunc. If you need to create your own
/// [`Snapshot`][crate::Snapshot], use [`new()`][Self::new()].
///
/// # Implements
///
/// [`SnapshotExt`][trait@crate::prelude::SnapshotExt], [`trait@gdk::prelude::SnapshotExt`], [`trait@glib::ObjectExt`], [`SnapshotExtManual`][trait@crate::prelude::SnapshotExtManual]
#[doc(alias = "GtkSnapshot")]
pub struct Snapshot(Object<ffi::GtkSnapshot, ffi::GtkSnapshotClass>) @extends gdk::Snapshot;
match fn {
type_ => || ffi::gtk_snapshot_get_type(),
}
}
impl Snapshot {
pub const NONE: Option<&'static Snapshot> = None;
/// 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()) }
}
}
impl Default for Snapshot {
fn default() -> Self {
Self::new()
}
}
/// Trait containing all [`struct@Snapshot`] methods.
///
/// # Implementors
///
/// [`Snapshot`][struct@crate::Snapshot]
pub trait SnapshotExt: IsA<Snapshot> + 'static {
/// 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::Context`][crate::cairo::Context] suitable for drawing the contents of
/// the newly created render node
#[doc(alias = "gtk_snapshot_append_cairo")]
fn append_cairo(&self, bounds: &graphene::Rect) -> cairo::Context {
unsafe {
from_glib_full(ffi::gtk_snapshot_append_cairo(
self.as_ref().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 color to draw
/// ## `bounds`
/// the bounds for the new node
#[doc(alias = "gtk_snapshot_append_color")]
fn append_color(&self, color: &gdk::RGBA, bounds: &graphene::Rect) {
unsafe {
ffi::gtk_snapshot_append_color(
self.as_ref().to_glib_none().0,
color.to_glib_none().0,
bounds.to_glib_none().0,
);
}
}
/// Appends a conic gradient node with the given stops to @self.
/// ## `bounds`
/// the rectangle to render the gradient into
/// ## `center`
/// the center point of the conic gradient
/// ## `rotation`
/// the clockwise rotation in degrees of the starting angle.
/// 0 means the starting angle is the top.
/// ## `stops`
/// the color stops defining the gradient
#[doc(alias = "gtk_snapshot_append_conic_gradient")]
fn append_conic_gradient(
&self,
bounds: &graphene::Rect,
center: &graphene::Point,
rotation: f32,
stops: &[gsk::ColorStop],
) {
let n_stops = stops.len() as _;
unsafe {
ffi::gtk_snapshot_append_conic_gradient(
self.as_ref().to_glib_none().0,
bounds.to_glib_none().0,
center.to_glib_none().0,
rotation,
stops.to_glib_none().0,
n_stops,
);
}
}
/// A convenience method to fill a path with a color.
///
/// See [`push_fill()`][Self::push_fill()] if you need
/// to fill a path with more complex content than
/// a color.
/// ## `path`
/// The path describing the area to fill
/// ## `fill_rule`
/// The fill rule to use
/// ## `color`
/// the color to fill the path with
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
#[doc(alias = "gtk_snapshot_append_fill")]
fn append_fill(&self, path: &gsk::Path, fill_rule: gsk::FillRule, color: &gdk::RGBA) {
unsafe {
ffi::gtk_snapshot_append_fill(
self.as_ref().to_glib_none().0,
path.to_glib_none().0,
fill_rule.into_glib(),
color.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")]
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.as_ref().to_glib_none().0,
outline.to_glib_none().0,
color.to_glib_none().0,
dx,
dy,
spread,
blur_radius,
);
}
}
/// Creates render nodes for rendering @layout in the given foregound @color
/// and appends them to the current node of @self without changing the
/// current node. The current theme's foreground color for a widget can be
/// obtained with [`WidgetExt::color()`][crate::prelude::WidgetExt::color()].
///
/// Note that if the layout does not produce any visible output, then nodes
/// may not be added to the @self.
/// ## `layout`
/// the [`pango::Layout`][crate::pango::Layout] to render
/// ## `color`
/// the foreground color to render the layout in
#[doc(alias = "gtk_snapshot_append_layout")]
fn append_layout(&self, layout: &pango::Layout, color: &gdk::RGBA) {
unsafe {
ffi::gtk_snapshot_append_layout(
self.as_ref().to_glib_none().0,
layout.to_glib_none().0,
color.to_glib_none().0,
);
}
}
/// Appends a linear gradient node with the given stops to @self.
/// ## `bounds`
/// the rectangle to render the linear gradient into
/// ## `start_point`
/// the point at which the linear gradient will begin
/// ## `end_point`
/// the point at which the linear gradient will finish
/// ## `stops`
/// the color stops defining the gradient
#[doc(alias = "gtk_snapshot_append_linear_gradient")]
fn append_linear_gradient(
&self,
bounds: &graphene::Rect,
start_point: &graphene::Point,
end_point: &graphene::Point,
stops: &[gsk::ColorStop],
) {
let n_stops = stops.len() as _;
unsafe {
ffi::gtk_snapshot_append_linear_gradient(
self.as_ref().to_glib_none().0,
bounds.to_glib_none().0,
start_point.to_glib_none().0,
end_point.to_glib_none().0,
stops.to_glib_none().0,
n_stops,
);
}
}
/// Appends @node to the current render node of @self,
/// without changing the current node.
///
/// If @self does not have a current node yet, @node
/// will become the initial node.
/// ## `node`
/// a [`gsk::RenderNode`][crate::gsk::RenderNode]
#[doc(alias = "gtk_snapshot_append_node")]
fn append_node(&self, node: impl AsRef<gsk::RenderNode>) {
unsafe {
ffi::gtk_snapshot_append_node(
self.as_ref().to_glib_none().0,
node.as_ref().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")]
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.as_ref().to_glib_none().0,
outline.to_glib_none().0,
color.to_glib_none().0,
dx,
dy,
spread,
blur_radius,
);
}
}
/// Appends a radial gradient node with the given stops to @self.
/// ## `bounds`
/// the rectangle to render the readial gradient into
/// ## `center`
/// the center point for the radial gradient
/// ## `hradius`
/// the horizontal radius
/// ## `vradius`
/// the vertical radius
/// ## `start`
/// the start position (on the horizontal axis)
/// ## `end`
/// the end position (on the horizontal axis)
/// ## `stops`
/// the color stops defining the gradient
#[doc(alias = "gtk_snapshot_append_radial_gradient")]
fn append_radial_gradient(
&self,
bounds: &graphene::Rect,
center: &graphene::Point,
hradius: f32,
vradius: f32,
start: f32,
end: f32,
stops: &[gsk::ColorStop],
) {
let n_stops = stops.len() as _;
unsafe {
ffi::gtk_snapshot_append_radial_gradient(
self.as_ref().to_glib_none().0,
bounds.to_glib_none().0,
center.to_glib_none().0,
hradius,
vradius,
start,
end,
stops.to_glib_none().0,
n_stops,
);
}
}
/// Appends a repeating linear gradient node with the given stops to @self.
/// ## `bounds`
/// the rectangle to render the linear gradient into
/// ## `start_point`
/// the point at which the linear gradient will begin
/// ## `end_point`
/// the point at which the linear gradient will finish
/// ## `stops`
/// the color stops defining the gradient
#[doc(alias = "gtk_snapshot_append_repeating_linear_gradient")]
fn append_repeating_linear_gradient(
&self,
bounds: &graphene::Rect,
start_point: &graphene::Point,
end_point: &graphene::Point,
stops: &[gsk::ColorStop],
) {
let n_stops = stops.len() as _;
unsafe {
ffi::gtk_snapshot_append_repeating_linear_gradient(
self.as_ref().to_glib_none().0,
bounds.to_glib_none().0,
start_point.to_glib_none().0,
end_point.to_glib_none().0,
stops.to_glib_none().0,
n_stops,
);
}
}
/// Appends a repeating radial gradient node with the given stops to @self.
/// ## `bounds`
/// the rectangle to render the readial gradient into
/// ## `center`
/// the center point for the radial gradient
/// ## `hradius`
/// the horizontal radius
/// ## `vradius`
/// the vertical radius
/// ## `start`
/// the start position (on the horizontal axis)
/// ## `end`
/// the end position (on the horizontal axis)
/// ## `stops`
/// the color stops defining the gradient
#[doc(alias = "gtk_snapshot_append_repeating_radial_gradient")]
fn append_repeating_radial_gradient(
&self,
bounds: &graphene::Rect,
center: &graphene::Point,
hradius: f32,
vradius: f32,
start: f32,
end: f32,
stops: &[gsk::ColorStop],
) {
let n_stops = stops.len() as _;
unsafe {
ffi::gtk_snapshot_append_repeating_radial_gradient(
self.as_ref().to_glib_none().0,
bounds.to_glib_none().0,
center.to_glib_none().0,
hradius,
vradius,
start,
end,
stops.to_glib_none().0,
n_stops,
);
}
}
/// Creates a new render node drawing the @texture
/// into the given @bounds and appends it to the
/// current render node of @self.
///
/// In contrast to [`append_texture()`][Self::append_texture()],
/// this function provides control about how the filter
/// that is used when scaling.
/// ## `texture`
/// the texture to render
/// ## `filter`
/// the filter to use
/// ## `bounds`
/// the bounds for the new node
#[cfg(feature = "v4_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
#[doc(alias = "gtk_snapshot_append_scaled_texture")]
fn append_scaled_texture(
&self,
texture: &impl IsA<gdk::Texture>,
filter: gsk::ScalingFilter,
bounds: &graphene::Rect,
) {
unsafe {
ffi::gtk_snapshot_append_scaled_texture(
self.as_ref().to_glib_none().0,
texture.as_ref().to_glib_none().0,
filter.into_glib(),
bounds.to_glib_none().0,
);
}
}
/// A convenience method to stroke a path with a color.
///
/// See [`push_stroke()`][Self::push_stroke()] if you need
/// to stroke a path with more complex content than
/// a color.
/// ## `path`
/// The path describing the area to fill
/// ## `stroke`
/// The stroke attributes
/// ## `color`
/// the color to fill the path with
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
#[doc(alias = "gtk_snapshot_append_stroke")]
fn append_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke, color: &gdk::RGBA) {
unsafe {
ffi::gtk_snapshot_append_stroke(
self.as_ref().to_glib_none().0,
path.to_glib_none().0,
stroke.to_glib_none().0,
color.to_glib_none().0,
);
}
}
/// Creates a new render node drawing the @texture
/// into the given @bounds and appends it to the
/// current render node of @self.
///
/// If the texture needs to be scaled to fill @bounds,
/// linear filtering is used. See [`append_scaled_texture()`][Self::append_scaled_texture()]
/// if you need other filtering, such as nearest-neighbour.
/// ## `texture`
/// the texture to render
/// ## `bounds`
/// the bounds for the new node
#[doc(alias = "gtk_snapshot_append_texture")]
fn append_texture(&self, texture: &impl IsA<gdk::Texture>, bounds: &graphene::Rect) {
unsafe {
ffi::gtk_snapshot_append_texture(
self.as_ref().to_glib_none().0,
texture.as_ref().to_glib_none().0,
bounds.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()].
///
/// # Deprecated since 4.16
///
/// GTK's new Vulkan-focused rendering
/// does not support this feature. Use [`GLArea`][crate::GLArea] for
/// OpenGL rendering.
#[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_gl_shader_pop_texture")]
fn gl_shader_pop_texture(&self) {
unsafe {
ffi::gtk_snapshot_gl_shader_pop_texture(self.as_ref().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")]
fn perspective(&self, depth: f32) {
unsafe {
ffi::gtk_snapshot_perspective(self.as_ref().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")]
fn pop(&self) {
unsafe {
ffi::gtk_snapshot_pop(self.as_ref().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")]
fn push_blend(&self, blend_mode: gsk::BlendMode) {
unsafe {
ffi::gtk_snapshot_push_blend(self.as_ref().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. Must be positive
#[doc(alias = "gtk_snapshot_push_blur")]
fn push_blur(&self, radius: f64) {
unsafe {
ffi::gtk_snapshot_push_blur(self.as_ref().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")]
fn push_clip(&self, bounds: &graphene::Rect) {
unsafe {
ffi::gtk_snapshot_push_clip(self.as_ref().to_glib_none().0, bounds.to_glib_none().0);
}
}
/// Modifies the colors of an image by applying an affine transformation
/// in RGB space.
///
/// In particular, the colors will be transformed by applying
///
/// pixel = transpose(color_matrix) * pixel + color_offset
///
/// for every pixel. The transformation operates on unpremultiplied
/// colors, with color components ordered R, G, B, A.
///
/// 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")]
fn push_color_matrix(&self, color_matrix: &graphene::Matrix, color_offset: &graphene::Vec4) {
unsafe {
ffi::gtk_snapshot_push_color_matrix(
self.as_ref().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")]
fn push_cross_fade(&self, progress: f64) {
unsafe {
ffi::gtk_snapshot_push_cross_fade(self.as_ref().to_glib_none().0, progress);
}
}
/// Fills the area given by @path and @fill_rule with an image and discards everything
/// outside of it.
///
/// The image is recorded until the next call to [`pop()`][Self::pop()].
///
/// If you want to fill the path with a color, [`append_fill()`][Self::append_fill()]
/// may be more convenient.
/// ## `path`
/// The path describing the area to fill
/// ## `fill_rule`
/// The fill rule to use
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
#[doc(alias = "gtk_snapshot_push_fill")]
fn push_fill(&self, path: &gsk::Path, fill_rule: gsk::FillRule) {
unsafe {
ffi::gtk_snapshot_push_fill(
self.as_ref().to_glib_none().0,
path.to_glib_none().0,
fill_rule.into_glib(),
);
}
}
/// 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].
///
/// # Deprecated since 4.16
///
/// GTK's new Vulkan-focused rendering
/// does not support this feature. Use [`GLArea`][crate::GLArea] for
/// OpenGL rendering.
/// ## `shader`
/// The code to run
/// ## `bounds`
/// the rectangle to render into
/// ## `take_args`
/// Data block with arguments for the shader.
#[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_push_gl_shader")]
fn push_gl_shader(
&self,
shader: &gsk::GLShader,
bounds: &graphene::Rect,
take_args: glib::Bytes,
) {
unsafe {
ffi::gtk_snapshot_push_gl_shader(
self.as_ref().to_glib_none().0,
shader.to_glib_none().0,
bounds.to_glib_none().0,
take_args.into_glib_ptr(),
);
}
}
/// Until the first call to [`pop()`][Self::pop()], the
/// mask image for the mask operation will be recorded.
///
/// After that call, the source image will be recorded until
/// the second call to [`pop()`][Self::pop()].
///
/// Calling this function requires 2 subsequent calls to gtk_snapshot_pop().
/// ## `mask_mode`
/// mask mode to use
#[cfg(feature = "v4_10")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
#[doc(alias = "gtk_snapshot_push_mask")]
fn push_mask(&self, mask_mode: gsk::MaskMode) {
unsafe {
ffi::gtk_snapshot_push_mask(self.as_ref().to_glib_none().0, mask_mode.into_glib());
}
}
/// 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")]
fn push_opacity(&self, opacity: f64) {
unsafe {
ffi::gtk_snapshot_push_opacity(self.as_ref().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")]
fn push_repeat(&self, bounds: &graphene::Rect, child_bounds: Option<&graphene::Rect>) {
unsafe {
ffi::gtk_snapshot_push_repeat(
self.as_ref().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")]
fn push_rounded_clip(&self, bounds: &gsk::RoundedRect) {
unsafe {
ffi::gtk_snapshot_push_rounded_clip(
self.as_ref().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
#[doc(alias = "gtk_snapshot_push_shadow")]
fn push_shadow(&self, shadow: &[gsk::Shadow]) {
let n_shadows = shadow.len() as _;
unsafe {
ffi::gtk_snapshot_push_shadow(
self.as_ref().to_glib_none().0,
shadow.to_glib_none().0,
n_shadows,
);
}
}
/// Strokes the given @path with the attributes given by @stroke and
/// an image.
///
/// The image is recorded until the next call to [`pop()`][Self::pop()].
///
/// Note that the strokes are subject to the same transformation as
/// everything else, so uneven scaling will cause horizontal and vertical
/// strokes to have different widths.
///
/// If you want to stroke the path with a color, [`append_stroke()`][Self::append_stroke()]
/// may be more convenient.
/// ## `path`
/// The path to stroke
/// ## `stroke`
/// The stroke attributes
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
#[doc(alias = "gtk_snapshot_push_stroke")]
fn push_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke) {
unsafe {
ffi::gtk_snapshot_push_stroke(
self.as_ref().to_glib_none().0,
path.to_glib_none().0,
stroke.to_glib_none().0,
);
}
}
/// 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.
///
/// # Deprecated since 4.10
///
/// ## `context`
/// the style context that defines the background
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `width`
/// rectangle width
/// ## `height`
/// rectangle height
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_render_background")]
fn render_background(
&self,
context: &impl IsA<StyleContext>,
x: f64,
y: f64,
width: f64,
height: f64,
) {
unsafe {
ffi::gtk_snapshot_render_background(
self.as_ref().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.
///
/// # Deprecated since 4.10
///
/// ## `context`
/// the style context that defines the focus ring
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `width`
/// rectangle width
/// ## `height`
/// rectangle height
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_render_focus")]
fn render_focus(
&self,
context: &impl IsA<StyleContext>,
x: f64,
y: f64,
width: f64,
height: f64,
) {
unsafe {
ffi::gtk_snapshot_render_focus(
self.as_ref().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.
///
/// # Deprecated since 4.10
///
/// ## `context`
/// the style context that defines the frame
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `width`
/// rectangle width
/// ## `height`
/// rectangle height
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_render_frame")]
fn render_frame(
&self,
context: &impl IsA<StyleContext>,
x: f64,
y: f64,
width: f64,
height: f64,
) {
unsafe {
ffi::gtk_snapshot_render_frame(
self.as_ref().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.
///
/// # Deprecated since 4.10
///
/// ## `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
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_render_insertion_cursor")]
fn render_insertion_cursor(
&self,
context: &impl IsA<StyleContext>,
x: f64,
y: f64,
layout: &pango::Layout,
index: i32,
direction: pango::Direction,
) {
unsafe {
ffi::gtk_snapshot_render_insertion_cursor(
self.as_ref().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.
///
/// # Deprecated since 4.10
///
/// ## `context`
/// the style context that defines the text
/// ## `x`
/// X origin of the rectangle
/// ## `y`
/// Y origin of the rectangle
/// ## `layout`
/// the [`pango::Layout`][crate::pango::Layout] to render
#[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
#[allow(deprecated)]
#[doc(alias = "gtk_snapshot_render_layout")]
fn render_layout(
&self,
context: &impl IsA<StyleContext>,
x: f64,
y: f64,
layout: &pango::Layout,
) {
unsafe {
ffi::gtk_snapshot_render_layout(
self.as_ref().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")]
fn restore(&self) {
unsafe {
ffi::gtk_snapshot_restore(self.as_ref().to_glib_none().0);
}
}
/// Rotates @@self's coordinate system by @angle degrees in 2D space -
/// or in 3D speak, rotates around the Z axis. The rotation happens around
/// the origin point of (0, 0) in the @self's current coordinate system.
///
/// To rotate around axes other than the Z axis, use [`gsk::Transform::rotate_3d()`][crate::gsk::Transform::rotate_3d()].
/// ## `angle`
/// the rotation angle, in degrees (clockwise)
#[doc(alias = "gtk_snapshot_rotate")]
fn rotate(&self, angle: f32) {
unsafe {
ffi::gtk_snapshot_rotate(self.as_ref().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")]
fn rotate_3d(&self, angle: f32, axis: &graphene::Vec3) {
unsafe {
ffi::gtk_snapshot_rotate_3d(
self.as_ref().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 `gtk_snapshot_restore()` restores the state from
/// the matching paired `gtk_snapshot_save()`.
///
/// It is necessary to clear all saved states with corresponding
/// calls to `gtk_snapshot_restore()`.
#[doc(alias = "gtk_snapshot_save")]
fn save(&self) {
unsafe {
ffi::gtk_snapshot_save(self.as_ref().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")]
fn scale(&self, factor_x: f32, factor_y: f32) {
unsafe {
ffi::gtk_snapshot_scale(self.as_ref().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")]
fn scale_3d(&self, factor_x: f32, factor_y: f32, factor_z: f32) {
unsafe {
ffi::gtk_snapshot_scale_3d(
self.as_ref().to_glib_none().0,
factor_x,
factor_y,
factor_z,
);
}
}
/// Returns the render node that was constructed
/// by @self.
///
/// Note that this function may return [`None`] if nothing has been
/// added to the snapshot or if its content does not produce pixels
/// to be rendered.
///
/// 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 `GObject::Object::unref()`.
///
/// # Returns
///
/// the constructed [`gsk::RenderNode`][crate::gsk::RenderNode] or
/// [`None`] if there are no nodes to render.
#[doc(alias = "gtk_snapshot_to_node")]
fn to_node(self) -> Option<gsk::RenderNode> {
unsafe { from_glib_full(ffi::gtk_snapshot_to_node(self.upcast().into_glib_ptr())) }
}
/// 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 `GObject::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")]
fn to_paintable(self, size: Option<&graphene::Size>) -> Option<gdk::Paintable> {
unsafe {
from_glib_full(ffi::gtk_snapshot_to_paintable(
self.upcast().into_glib_ptr(),
size.to_glib_none().0,
))
}
}
/// Transforms @self's coordinate system with the given @transform.
/// ## `transform`
/// the transform to apply
#[doc(alias = "gtk_snapshot_transform")]
fn transform(&self, transform: Option<&gsk::Transform>) {
unsafe {
ffi::gtk_snapshot_transform(self.as_ref().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")]
fn transform_matrix(&self, matrix: &graphene::Matrix) {
unsafe {
ffi::gtk_snapshot_transform_matrix(
self.as_ref().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")]
fn translate(&self, point: &graphene::Point) {
unsafe {
ffi::gtk_snapshot_translate(self.as_ref().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")]
fn translate_3d(&self, point: &graphene::Point3D) {
unsafe {
ffi::gtk_snapshot_translate_3d(self.as_ref().to_glib_none().0, point.to_glib_none().0);
}
}
}
impl<O: IsA<Snapshot>> SnapshotExt for O {}