1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.Snapshot; 26 27 private import cairo.Context; 28 private import gdk.PaintableIF; 29 private import gdk.RGBA; 30 private import gdk.Snapshot : DGdkSnapshot = Snapshot; 31 private import gdk.Texture; 32 private import glib.Bytes; 33 private import glib.ConstructionException; 34 private import glib.Str; 35 private import gobject.ObjectG; 36 private import graphene.Matrix; 37 private import graphene.Point; 38 private import graphene.Point3D; 39 private import graphene.Rect; 40 private import graphene.Size; 41 private import graphene.Vec3; 42 private import graphene.Vec4; 43 private import gsk.GLShader; 44 private import gsk.RenderNode; 45 private import gsk.RoundedRect; 46 private import gsk.Transform; 47 private import gtk.StyleContext; 48 private import gtk.c.functions; 49 public import gtk.c.types; 50 private import pango.PgLayout; 51 52 53 /** 54 * `GtkSnapshot` assists in creating `GskRenderNodes` for widgets. 55 * 56 * It functions in a similar way to a cairo context, and maintains a stack 57 * of render nodes and their associated transformations. 58 * 59 * The node at the top of the stack is the the one that gtk_snapshot_append_… 60 * functions operate on. Use the gtk_snapshot_push_… functions and 61 * gtk_snapshot_pop() to change the current node. 62 * 63 * The typical way to obtain a `GtkSnapshot` object is as an argument to 64 * the GtkWidgetClass.snapshot() vfunc. If you need to create your own 65 * `GtkSnapshot`, use [ctor@Gtk.Snapshot.new]. 66 */ 67 public class Snapshot : DGdkSnapshot 68 { 69 /** the main Gtk struct */ 70 protected GtkSnapshot* gtkSnapshot; 71 72 /** Get the main Gtk struct */ 73 public GtkSnapshot* getGtkSnapshotStruct(bool transferOwnership = false) 74 { 75 if (transferOwnership) 76 ownedRef = false; 77 return gtkSnapshot; 78 } 79 80 /** the main Gtk struct as a void* */ 81 protected override void* getStruct() 82 { 83 return cast(void*)gtkSnapshot; 84 } 85 86 /** 87 * Sets our main struct and passes it to the parent class. 88 */ 89 public this (GtkSnapshot* gtkSnapshot, bool ownedRef = false) 90 { 91 this.gtkSnapshot = gtkSnapshot; 92 super(cast(GdkSnapshot*)gtkSnapshot, ownedRef); 93 } 94 95 96 /** */ 97 public static GType getType() 98 { 99 return gtk_snapshot_get_type(); 100 } 101 102 /** 103 * Creates a new `GtkSnapshot`. 104 * 105 * Returns: a newly-allocated `GtkSnapshot` 106 * 107 * Throws: ConstructionException GTK+ fails to create the object. 108 */ 109 public this() 110 { 111 auto __p = gtk_snapshot_new(); 112 113 if(__p is null) 114 { 115 throw new ConstructionException("null returned by new"); 116 } 117 118 this(cast(GtkSnapshot*) __p, true); 119 } 120 121 /** 122 * Appends a stroked border rectangle inside the given @outline. 123 * 124 * The four sides of the border can have different widths and colors. 125 * 126 * Params: 127 * outline = a `GskRoundedRect` describing the outline of the border 128 * borderWidth = the stroke width of the border on 129 * the top, right, bottom and left side respectively. 130 * borderColor = the color used on the top, right, 131 * bottom and left side. 132 */ 133 public void appendBorder(RoundedRect outline, float[4] borderWidth, RGBA[4] borderColor) 134 { 135 GdkRGBA[] borderColorArray = new GdkRGBA[borderColor.length]; 136 for ( int i = 0; i < borderColor.length; i++ ) 137 { 138 borderColorArray[i] = *(borderColor[i].getRGBAStruct()); 139 } 140 141 gtk_snapshot_append_border(gtkSnapshot, (outline is null) ? null : outline.getRoundedRectStruct(), borderWidth.ptr, borderColorArray.ptr); 142 } 143 144 /** 145 * Creates a new `GskCairoNode` and appends it to the current 146 * render node of @snapshot, without changing the current node. 147 * 148 * Params: 149 * bounds = the bounds for the new node 150 * 151 * Returns: a `cairo_t` suitable for drawing the contents of 152 * the newly created render node 153 */ 154 public Context appendCairo(Rect bounds) 155 { 156 auto __p = gtk_snapshot_append_cairo(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct()); 157 158 if(__p is null) 159 { 160 return null; 161 } 162 163 return new Context(cast(cairo_t*) __p); 164 } 165 166 /** 167 * Creates a new render node drawing the @color into the 168 * given @bounds and appends it to the current render node 169 * of @snapshot. 170 * 171 * You should try to avoid calling this function if 172 * @color is transparent. 173 * 174 * Params: 175 * color = the `GdkRGBA` to draw 176 * bounds = the bounds for the new node 177 */ 178 public void appendColor(RGBA color, Rect bounds) 179 { 180 gtk_snapshot_append_color(gtkSnapshot, (color is null) ? null : color.getRGBAStruct(), (bounds is null) ? null : bounds.getRectStruct()); 181 } 182 183 /** 184 * Appends a conic gradient node with the given stops to @snapshot. 185 * 186 * Params: 187 * bounds = the rectangle to render the gradient into 188 * center = the center point of the conic gradient 189 * rotation = the clockwise rotation in degrees of the starting angle. 190 * 0 means the starting angle is the top. 191 * stops = a pointer to an array of `GskColorStop` 192 * defining the gradient 193 */ 194 public void appendConicGradient(Rect bounds, Point center, float rotation, GskColorStop[] stops) 195 { 196 gtk_snapshot_append_conic_gradient(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct(), (center is null) ? null : center.getPointStruct(), rotation, stops.ptr, cast(size_t)stops.length); 197 } 198 199 /** 200 * Appends an inset shadow into the box given by @outline. 201 * 202 * Params: 203 * outline = outline of the region surrounded by shadow 204 * color = color of the shadow 205 * dx = horizontal offset of shadow 206 * dy = vertical offset of shadow 207 * spread = how far the shadow spreads towards the inside 208 * blurRadius = how much blur to apply to the shadow 209 */ 210 public void appendInsetShadow(RoundedRect outline, RGBA color, float dx, float dy, float spread, float blurRadius) 211 { 212 gtk_snapshot_append_inset_shadow(gtkSnapshot, (outline is null) ? null : outline.getRoundedRectStruct(), (color is null) ? null : color.getRGBAStruct(), dx, dy, spread, blurRadius); 213 } 214 215 /** */ 216 public void appendLayout(PgLayout layout, RGBA color) 217 { 218 gtk_snapshot_append_layout(gtkSnapshot, (layout is null) ? null : layout.getPgLayoutStruct(), (color is null) ? null : color.getRGBAStruct()); 219 } 220 221 /** 222 * Appends a linear gradient node with the given stops to @snapshot. 223 * 224 * Params: 225 * bounds = the rectangle to render the linear gradient into 226 * startPoint = the point at which the linear gradient will begin 227 * endPoint = the point at which the linear gradient will finish 228 * stops = a pointer to an array of `GskColorStop` 229 * defining the gradient 230 */ 231 public void appendLinearGradient(Rect bounds, Point startPoint, Point endPoint, GskColorStop[] stops) 232 { 233 gtk_snapshot_append_linear_gradient(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct(), (startPoint is null) ? null : startPoint.getPointStruct(), (endPoint is null) ? null : endPoint.getPointStruct(), stops.ptr, cast(size_t)stops.length); 234 } 235 236 /** 237 * Appends @node to the current render node of @snapshot, 238 * without changing the current node. 239 * 240 * If @snapshot does not have a current node yet, @node 241 * will become the initial node. 242 * 243 * Params: 244 * node = a #GskRenderNode 245 */ 246 public void appendNode(RenderNode node) 247 { 248 gtk_snapshot_append_node(gtkSnapshot, (node is null) ? null : node.getRenderNodeStruct()); 249 } 250 251 /** 252 * Appends an outset shadow node around the box given by @outline. 253 * 254 * Params: 255 * outline = outline of the region surrounded by shadow 256 * color = color of the shadow 257 * dx = horizontal offset of shadow 258 * dy = vertical offset of shadow 259 * spread = how far the shadow spreads towards the outside 260 * blurRadius = how much blur to apply to the shadow 261 */ 262 public void appendOutsetShadow(RoundedRect outline, RGBA color, float dx, float dy, float spread, float blurRadius) 263 { 264 gtk_snapshot_append_outset_shadow(gtkSnapshot, (outline is null) ? null : outline.getRoundedRectStruct(), (color is null) ? null : color.getRGBAStruct(), dx, dy, spread, blurRadius); 265 } 266 267 /** 268 * Appends a radial gradient node with the given stops to @snapshot. 269 * 270 * Params: 271 * bounds = the rectangle to render the readial gradient into 272 * center = the center point for the radial gradient 273 * hradius = the horizontal radius 274 * vradius = the vertical radius 275 * start = the start position (on the horizontal axis) 276 * end = the end position (on the horizontal axis) 277 * stops = a pointer to an array of `GskColorStop` 278 * defining the gradient 279 */ 280 public void appendRadialGradient(Rect bounds, Point center, float hradius, float vradius, float start, float end, GskColorStop[] stops) 281 { 282 gtk_snapshot_append_radial_gradient(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct(), (center is null) ? null : center.getPointStruct(), hradius, vradius, start, end, stops.ptr, cast(size_t)stops.length); 283 } 284 285 /** 286 * Appends a repeating linear gradient node with the given stops to @snapshot. 287 * 288 * Params: 289 * bounds = the rectangle to render the linear gradient into 290 * startPoint = the point at which the linear gradient will begin 291 * endPoint = the point at which the linear gradient will finish 292 * stops = a pointer to an array of `GskColorStop` 293 * defining the gradient 294 */ 295 public void appendRepeatingLinearGradient(Rect bounds, Point startPoint, Point endPoint, GskColorStop[] stops) 296 { 297 gtk_snapshot_append_repeating_linear_gradient(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct(), (startPoint is null) ? null : startPoint.getPointStruct(), (endPoint is null) ? null : endPoint.getPointStruct(), stops.ptr, cast(size_t)stops.length); 298 } 299 300 /** 301 * Appends a repeating radial gradient node with the given stops to @snapshot. 302 * 303 * Params: 304 * bounds = the rectangle to render the readial gradient into 305 * center = the center point for the radial gradient 306 * hradius = the horizontal radius 307 * vradius = the vertical radius 308 * start = the start position (on the horizontal axis) 309 * end = the end position (on the horizontal axis) 310 * stops = a pointer to an array of `GskColorStop` 311 * defining the gradient 312 */ 313 public void appendRepeatingRadialGradient(Rect bounds, Point center, float hradius, float vradius, float start, float end, GskColorStop[] stops) 314 { 315 gtk_snapshot_append_repeating_radial_gradient(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct(), (center is null) ? null : center.getPointStruct(), hradius, vradius, start, end, stops.ptr, cast(size_t)stops.length); 316 } 317 318 /** 319 * Creates a new render node drawing the @texture 320 * into the given @bounds and appends it to the 321 * current render node of @snapshot. 322 * 323 * Params: 324 * texture = the `GdkTexture` to render 325 * bounds = the bounds for the new node 326 */ 327 public void appendTexture(Texture texture, Rect bounds) 328 { 329 gtk_snapshot_append_texture(gtkSnapshot, (texture is null) ? null : texture.getTextureStruct(), (bounds is null) ? null : bounds.getRectStruct()); 330 } 331 332 /** 333 * Returns the node that was constructed by @snapshot 334 * and frees @snapshot. 335 * 336 * Returns: a newly-created `GskRenderNode` 337 */ 338 public RenderNode freeToNode() 339 { 340 auto __p = gtk_snapshot_free_to_node(gtkSnapshot); 341 342 if(__p is null) 343 { 344 return null; 345 } 346 347 return ObjectG.getDObject!(RenderNode)(cast(GskRenderNode*) __p, true); 348 } 349 350 /** 351 * Returns a paintable for the node that was 352 * constructed by @snapshot and frees @snapshot. 353 * 354 * Params: 355 * size = The size of the resulting paintable 356 * or %NULL to use the bounds of the snapshot 357 * 358 * Returns: a newly-created `GdkPaintable` 359 */ 360 public PaintableIF freeToPaintable(Size size) 361 { 362 auto __p = gtk_snapshot_free_to_paintable(gtkSnapshot, (size is null) ? null : size.getSizeStruct()); 363 364 if(__p is null) 365 { 366 return null; 367 } 368 369 return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p, true); 370 } 371 372 /** 373 * Removes the top element from the stack of render nodes and 374 * adds it to the nearest `GskGLShaderNode` below it. 375 * 376 * This must be called the same number of times as the number 377 * of textures is needed for the shader in 378 * [method@Gtk.Snapshot.push_gl_shader]. 379 */ 380 public void glShaderPopTexture() 381 { 382 gtk_snapshot_gl_shader_pop_texture(gtkSnapshot); 383 } 384 385 /** 386 * Applies a perspective projection transform. 387 * 388 * See [method@Gsk.Transform.perspective] for a discussion on the details. 389 * 390 * Params: 391 * depth = distance of the z=0 plane 392 */ 393 public void perspective(float depth) 394 { 395 gtk_snapshot_perspective(gtkSnapshot, depth); 396 } 397 398 /** 399 * Removes the top element from the stack of render nodes, 400 * and appends it to the node underneath it. 401 */ 402 public void pop() 403 { 404 gtk_snapshot_pop(gtkSnapshot); 405 } 406 407 /** 408 * Blends together two images with the given blend mode. 409 * 410 * Until the first call to [method@Gtk.Snapshot.pop], the 411 * bottom image for the blend operation will be recorded. 412 * After that call, the top image to be blended will be 413 * recorded until the second call to [method@Gtk.Snapshot.pop]. 414 * 415 * Calling this function requires two subsequent calls 416 * to [method@Gtk.Snapshot.pop]. 417 * 418 * Params: 419 * blendMode = blend mode to use 420 */ 421 public void pushBlend(GskBlendMode blendMode) 422 { 423 gtk_snapshot_push_blend(gtkSnapshot, blendMode); 424 } 425 426 /** 427 * Blurs an image. 428 * 429 * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. 430 * 431 * Params: 432 * radius = the blur radius to use 433 */ 434 public void pushBlur(double radius) 435 { 436 gtk_snapshot_push_blur(gtkSnapshot, radius); 437 } 438 439 /** 440 * Clips an image to a rectangle. 441 * 442 * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. 443 * 444 * Params: 445 * bounds = the rectangle to clip to 446 */ 447 public void pushClip(Rect bounds) 448 { 449 gtk_snapshot_push_clip(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct()); 450 } 451 452 /** 453 * Modifies the colors of an image by applying an affine transformation 454 * in RGB space. 455 * 456 * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. 457 * 458 * Params: 459 * colorMatrix = the color matrix to use 460 * colorOffset = the color offset to use 461 */ 462 public void pushColorMatrix(Matrix colorMatrix, Vec4 colorOffset) 463 { 464 gtk_snapshot_push_color_matrix(gtkSnapshot, (colorMatrix is null) ? null : colorMatrix.getMatrixStruct(), (colorOffset is null) ? null : colorOffset.getVec4Struct()); 465 } 466 467 /** 468 * Snapshots a cross-fade operation between two images with the 469 * given @progress. 470 * 471 * Until the first call to [method@Gtk.Snapshot.pop], the start image 472 * will be snapshot. After that call, the end image will be recorded 473 * until the second call to [method@Gtk.Snapshot.pop]. 474 * 475 * Calling this function requires two subsequent calls 476 * to [method@Gtk.Snapshot.pop]. 477 * 478 * Params: 479 * progress = progress between 0.0 and 1.0 480 */ 481 public void pushCrossFade(double progress) 482 { 483 gtk_snapshot_push_cross_fade(gtkSnapshot, progress); 484 } 485 486 /** 487 * Push a `GskGLShaderNode`. 488 * 489 * The node uses the given [class@Gsk.GLShader] and uniform values 490 * Additionally this takes a list of @n_children other nodes 491 * which will be passed to the `GskGLShaderNode`. 492 * 493 * The @take_args argument is a block of data to use for uniform 494 * arguments, as per types and offsets defined by the @shader. 495 * Normally this is generated by [method@Gsk.GLShader.format_args] 496 * or [struct@Gsk.ShaderArgsBuilder]. 497 * 498 * The snapshotter takes ownership of @take_args, so the caller should 499 * not free it after this. 500 * 501 * If the renderer doesn't support GL shaders, or if there is any 502 * problem when compiling the shader, then the node will draw pink. 503 * You should use [method@Gsk.GLShader.compile] to ensure the @shader 504 * will work for the renderer before using it. 505 * 506 * If the shader requires textures (see [method@Gsk.GLShader.get_n_textures]), 507 * then it is expected that you call [method@Gtk.Snapshot.gl_shader_pop_texture] 508 * the number of times that are required. Each of these calls will generate 509 * a node that is added as a child to the `GskGLShaderNode`, which in turn 510 * will render these offscreen and pass as a texture to the shader. 511 * 512 * Once all textures (if any) are pop:ed, you must call the regular 513 * [method@Gtk.Snapshot.pop]. 514 * 515 * If you want to use pre-existing textures as input to the shader rather 516 * than rendering new ones, use [method@Gtk.Snapshot.append_texture] to 517 * push a texture node. These will be used directly rather than being 518 * re-rendered. 519 * 520 * For details on how to write shaders, see [class@Gsk.GLShader]. 521 * 522 * Params: 523 * shader = The code to run 524 * bounds = the rectangle to render into 525 * takeArgs = Data block with arguments for the shader. 526 */ 527 public void pushGlShader(GLShader shader, Rect bounds, Bytes takeArgs) 528 { 529 gtk_snapshot_push_gl_shader(gtkSnapshot, (shader is null) ? null : shader.getGLShaderStruct(), (bounds is null) ? null : bounds.getRectStruct(), (takeArgs is null) ? null : takeArgs.getBytesStruct(true)); 530 } 531 532 /** 533 * Modifies the opacity of an image. 534 * 535 * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. 536 * 537 * Params: 538 * opacity = the opacity to use 539 */ 540 public void pushOpacity(double opacity) 541 { 542 gtk_snapshot_push_opacity(gtkSnapshot, opacity); 543 } 544 545 /** 546 * Creates a node that repeats the child node. 547 * 548 * The child is recorded until the next call to [method@Gtk.Snapshot.pop]. 549 * 550 * Params: 551 * bounds = the bounds within which to repeat 552 * childBounds = the bounds of the child or %NULL 553 * to use the full size of the collected child node 554 */ 555 public void pushRepeat(Rect bounds, Rect childBounds) 556 { 557 gtk_snapshot_push_repeat(gtkSnapshot, (bounds is null) ? null : bounds.getRectStruct(), (childBounds is null) ? null : childBounds.getRectStruct()); 558 } 559 560 /** 561 * Clips an image to a rounded rectangle. 562 * 563 * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. 564 * 565 * Params: 566 * bounds = the rounded rectangle to clip to 567 */ 568 public void pushRoundedClip(RoundedRect bounds) 569 { 570 gtk_snapshot_push_rounded_clip(gtkSnapshot, (bounds is null) ? null : bounds.getRoundedRectStruct()); 571 } 572 573 /** 574 * Applies a shadow to an image. 575 * 576 * The image is recorded until the next call to [method@Gtk.Snapshot.pop]. 577 * 578 * Params: 579 * shadow = the first shadow specification 580 * nShadows = number of shadow specifications 581 */ 582 public void pushShadow(GskShadow* shadow, size_t nShadows) 583 { 584 gtk_snapshot_push_shadow(gtkSnapshot, shadow, nShadows); 585 } 586 587 /** 588 * Creates a render node for the CSS background according to @context, 589 * and appends it to the current node of @snapshot, without changing 590 * the current node. 591 * 592 * Params: 593 * context = the `GtkStyleContext` to use 594 * x = X origin of the rectangle 595 * y = Y origin of the rectangle 596 * width = rectangle width 597 * height = rectangle height 598 */ 599 public void renderBackground(StyleContext context, double x, double y, double width, double height) 600 { 601 gtk_snapshot_render_background(gtkSnapshot, (context is null) ? null : context.getStyleContextStruct(), x, y, width, height); 602 } 603 604 /** 605 * Creates a render node for the focus outline according to @context, 606 * and appends it to the current node of @snapshot, without changing 607 * the current node. 608 * 609 * Params: 610 * context = the `GtkStyleContext` to use 611 * x = X origin of the rectangle 612 * y = Y origin of the rectangle 613 * width = rectangle width 614 * height = rectangle height 615 */ 616 public void renderFocus(StyleContext context, double x, double y, double width, double height) 617 { 618 gtk_snapshot_render_focus(gtkSnapshot, (context is null) ? null : context.getStyleContextStruct(), x, y, width, height); 619 } 620 621 /** 622 * Creates a render node for the CSS border according to @context, 623 * and appends it to the current node of @snapshot, without changing 624 * the current node. 625 * 626 * Params: 627 * context = the `GtkStyleContext` to use 628 * x = X origin of the rectangle 629 * y = Y origin of the rectangle 630 * width = rectangle width 631 * height = rectangle height 632 */ 633 public void renderFrame(StyleContext context, double x, double y, double width, double height) 634 { 635 gtk_snapshot_render_frame(gtkSnapshot, (context is null) ? null : context.getStyleContextStruct(), x, y, width, height); 636 } 637 638 /** 639 * Draws a text caret using @snapshot at the specified index of @layout. 640 * 641 * Params: 642 * context = a `GtkStyleContext` 643 * x = X origin 644 * y = Y origin 645 * layout = the `PangoLayout` of the text 646 * index = the index in the #PangoLayout 647 * direction = the #PangoDirection of the text 648 */ 649 public void renderInsertionCursor(StyleContext context, double x, double y, PgLayout layout, int index, PangoDirection direction) 650 { 651 gtk_snapshot_render_insertion_cursor(gtkSnapshot, (context is null) ? null : context.getStyleContextStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct(), index, direction); 652 } 653 654 /** 655 * Creates a render node for rendering @layout according to the style 656 * information in @context, and appends it to the current node of @snapshot, 657 * without changing the current node. 658 * 659 * Params: 660 * context = the `GtkStyleContext` to use 661 * x = X origin of the rectangle 662 * y = Y origin of the rectangle 663 * layout = the #PangoLayout to render 664 */ 665 public void renderLayout(StyleContext context, double x, double y, PgLayout layout) 666 { 667 gtk_snapshot_render_layout(gtkSnapshot, (context is null) ? null : context.getStyleContextStruct(), x, y, (layout is null) ? null : layout.getPgLayoutStruct()); 668 } 669 670 /** 671 * Restores @snapshot to the state saved by a preceding call to 672 * gtk_snapshot_save() and removes that state from the stack of 673 * saved states. 674 */ 675 public void restore() 676 { 677 gtk_snapshot_restore(gtkSnapshot); 678 } 679 680 /** 681 * Rotates @@snapshot's coordinate system by @angle degrees in 2D space - 682 * or in 3D speak, rotates around the Z axis. 683 * 684 * To rotate around other axes, use [method@Gsk.Transform.rotate_3d]. 685 * 686 * Params: 687 * angle = the rotation angle, in degrees (clockwise) 688 */ 689 public void rotate(float angle) 690 { 691 gtk_snapshot_rotate(gtkSnapshot, angle); 692 } 693 694 /** 695 * Rotates @snapshot's coordinate system by @angle degrees around @axis. 696 * 697 * For a rotation in 2D space, use [method@Gsk.Transform.rotate]. 698 * 699 * Params: 700 * angle = the rotation angle, in degrees (clockwise) 701 * axis = The rotation axis 702 */ 703 public void rotate3d(float angle, Vec3 axis) 704 { 705 gtk_snapshot_rotate_3d(gtkSnapshot, angle, (axis is null) ? null : axis.getVec3Struct()); 706 } 707 708 /** 709 * Makes a copy of the current state of @snapshot and saves it 710 * on an internal stack. 711 * 712 * When [method@Gtk.Snapshot.restore] is called, @snapshot will 713 * be restored to the saved state. Multiple calls to 714 * gtk_snapshot_save() and gtk_snapshot_restore() can be nested; 715 * each call to gtk_snapshot_restore() restores the state from 716 * the matching paired gtk_snapshot_save(). 717 * 718 * It is necessary to clear all saved states with corresponding 719 * calls to gtk_snapshot_restore(). 720 */ 721 public void save() 722 { 723 gtk_snapshot_save(gtkSnapshot); 724 } 725 726 /** 727 * Scales @snapshot's coordinate system in 2-dimensional space by 728 * the given factors. 729 * 730 * Use [method@Gtk.Snapshot.scale_3d] to scale in all 3 dimensions. 731 * 732 * Params: 733 * factorX = scaling factor on the X axis 734 * factorY = scaling factor on the Y axis 735 */ 736 public void scale(float factorX, float factorY) 737 { 738 gtk_snapshot_scale(gtkSnapshot, factorX, factorY); 739 } 740 741 /** 742 * Scales @snapshot's coordinate system by the given factors. 743 * 744 * Params: 745 * factorX = scaling factor on the X axis 746 * factorY = scaling factor on the Y axis 747 * factorZ = scaling factor on the Z axis 748 */ 749 public void scale3d(float factorX, float factorY, float factorZ) 750 { 751 gtk_snapshot_scale_3d(gtkSnapshot, factorX, factorY, factorZ); 752 } 753 754 /** 755 * Returns the render node that was constructed 756 * by @snapshot. 757 * 758 * After calling this function, it is no longer possible to 759 * add more nodes to @snapshot. The only function that should 760 * be called after this is g_object_unref(). 761 * 762 * Returns: the constructed `GskRenderNode` 763 */ 764 public RenderNode toNode() 765 { 766 auto __p = gtk_snapshot_to_node(gtkSnapshot); 767 768 if(__p is null) 769 { 770 return null; 771 } 772 773 return ObjectG.getDObject!(RenderNode)(cast(GskRenderNode*) __p, true); 774 } 775 776 /** 777 * Returns a paintable encapsulating the render node 778 * that was constructed by @snapshot. 779 * 780 * After calling this function, it is no longer possible to 781 * add more nodes to @snapshot. The only function that should 782 * be called after this is g_object_unref(). 783 * 784 * Params: 785 * size = The size of the resulting paintable 786 * or %NULL to use the bounds of the snapshot 787 * 788 * Returns: a new #GdkPaintable 789 */ 790 public PaintableIF toPaintable(Size size) 791 { 792 auto __p = gtk_snapshot_to_paintable(gtkSnapshot, (size is null) ? null : size.getSizeStruct()); 793 794 if(__p is null) 795 { 796 return null; 797 } 798 799 return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p, true); 800 } 801 802 /** 803 * Transforms @snapshot's coordinate system with the given @transform. 804 * 805 * Params: 806 * transform = the transform to apply 807 */ 808 public void transform(Transform transform) 809 { 810 gtk_snapshot_transform(gtkSnapshot, (transform is null) ? null : transform.getTransformStruct()); 811 } 812 813 /** 814 * Transforms @snapshot's coordinate system with the given @matrix. 815 * 816 * Params: 817 * matrix = the matrix to multiply the transform with 818 */ 819 public void transformMatrix(Matrix matrix) 820 { 821 gtk_snapshot_transform_matrix(gtkSnapshot, (matrix is null) ? null : matrix.getMatrixStruct()); 822 } 823 824 /** 825 * Translates @snapshot's coordinate system by @point in 2-dimensional space. 826 * 827 * Params: 828 * point = the point to translate the snapshot by 829 */ 830 public void translate(Point point) 831 { 832 gtk_snapshot_translate(gtkSnapshot, (point is null) ? null : point.getPointStruct()); 833 } 834 835 /** 836 * Translates @snapshot's coordinate system by @point. 837 * 838 * Params: 839 * point = the point to translate the snapshot by 840 */ 841 public void translate3d(Point3D point) 842 { 843 gtk_snapshot_translate_3d(gtkSnapshot, (point is null) ? null : point.getPoint3DStruct()); 844 } 845 }