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 gdkpixbuf.PixbufAnimationIter; 26 27 private import gdkpixbuf.Pixbuf; 28 private import gdkpixbuf.c.functions; 29 public import gdkpixbuf.c.types; 30 private import glib.TimeVal; 31 private import gobject.ObjectG; 32 public import gtkc.gdkpixbuftypes; 33 34 35 /** 36 * An opaque struct representing an iterator which points to a 37 * certain position in an animation. 38 */ 39 public class PixbufAnimationIter : ObjectG 40 { 41 /** the main Gtk struct */ 42 protected GdkPixbufAnimationIter* gdkPixbufAnimationIter; 43 44 /** Get the main Gtk struct */ 45 public GdkPixbufAnimationIter* getPixbufAnimationIterStruct(bool transferOwnership = false) 46 { 47 if (transferOwnership) 48 ownedRef = false; 49 return gdkPixbufAnimationIter; 50 } 51 52 /** the main Gtk struct as a void* */ 53 protected override void* getStruct() 54 { 55 return cast(void*)gdkPixbufAnimationIter; 56 } 57 58 protected override void setStruct(GObject* obj) 59 { 60 gdkPixbufAnimationIter = cast(GdkPixbufAnimationIter*)obj; 61 super.setStruct(obj); 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (GdkPixbufAnimationIter* gdkPixbufAnimationIter, bool ownedRef = false) 68 { 69 this.gdkPixbufAnimationIter = gdkPixbufAnimationIter; 70 super(cast(GObject*)gdkPixbufAnimationIter, ownedRef); 71 } 72 73 74 /** */ 75 public static GType getType() 76 { 77 return gdk_pixbuf_animation_iter_get_type(); 78 } 79 80 /** 81 * Possibly advances an animation to a new frame. Chooses the frame based 82 * on the start time passed to gdk_pixbuf_animation_get_iter(). 83 * 84 * @current_time would normally come from g_get_current_time(), and 85 * must be greater than or equal to the time passed to 86 * gdk_pixbuf_animation_get_iter(), and must increase or remain 87 * unchanged each time gdk_pixbuf_animation_iter_get_pixbuf() is 88 * called. That is, you can't go backward in time; animations only 89 * play forward. 90 * 91 * As a shortcut, pass %NULL for the current time and g_get_current_time() 92 * will be invoked on your behalf. So you only need to explicitly pass 93 * @current_time if you're doing something odd like playing the animation 94 * at double speed. 95 * 96 * If this function returns %FALSE, there's no need to update the animation 97 * display, assuming the display had been rendered prior to advancing; 98 * if %TRUE, you need to call gdk_pixbuf_animation_iter_get_pixbuf() 99 * and update the display with the new pixbuf. 100 * 101 * Params: 102 * currentTime = current time 103 * 104 * Returns: %TRUE if the image may need updating 105 */ 106 public bool advance(TimeVal currentTime) 107 { 108 return gdk_pixbuf_animation_iter_advance(gdkPixbufAnimationIter, (currentTime is null) ? null : currentTime.getTimeValStruct()) != 0; 109 } 110 111 /** 112 * Gets the number of milliseconds the current pixbuf should be displayed, 113 * or -1 if the current pixbuf should be displayed forever. g_timeout_add() 114 * conveniently takes a timeout in milliseconds, so you can use a timeout 115 * to schedule the next update. 116 * 117 * Note that some formats, like GIF, might clamp the timeout values in the 118 * image file to avoid updates that are just too quick. The minimum timeout 119 * for GIF images is currently 20 milliseconds. 120 * 121 * Returns: delay time in milliseconds (thousandths of a second) 122 */ 123 public int getDelayTime() 124 { 125 return gdk_pixbuf_animation_iter_get_delay_time(gdkPixbufAnimationIter); 126 } 127 128 /** 129 * Gets the current pixbuf which should be displayed; the pixbuf might not 130 * be the same size as the animation itself 131 * (gdk_pixbuf_animation_get_width(), gdk_pixbuf_animation_get_height()). 132 * This pixbuf should be displayed for 133 * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. The caller 134 * of this function does not own a reference to the returned pixbuf; 135 * the returned pixbuf will become invalid when the iterator advances 136 * to the next frame, which may happen anytime you call 137 * gdk_pixbuf_animation_iter_advance(). Copy the pixbuf to keep it 138 * (don't just add a reference), as it may get recycled as you advance 139 * the iterator. 140 * 141 * Returns: the pixbuf to be displayed 142 */ 143 public Pixbuf getPixbuf() 144 { 145 auto p = gdk_pixbuf_animation_iter_get_pixbuf(gdkPixbufAnimationIter); 146 147 if(p is null) 148 { 149 return null; 150 } 151 152 return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p); 153 } 154 155 /** 156 * Used to determine how to respond to the area_updated signal on 157 * #GdkPixbufLoader when loading an animation. area_updated is emitted 158 * for an area of the frame currently streaming in to the loader. So if 159 * you're on the currently loading frame, you need to redraw the screen for 160 * the updated area. 161 * 162 * Returns: %TRUE if the frame we're on is partially loaded, or the last frame 163 */ 164 public bool onCurrentlyLoadingFrame() 165 { 166 return gdk_pixbuf_animation_iter_on_currently_loading_frame(gdkPixbufAnimationIter) != 0; 167 } 168 }