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
|
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<refentry id="class-gdkpixbufanimationiter">
<refnamediv>
<refname>gtk.gdk.PixbufAnimationIter</refname>
<refpurpose>an object providing access to the frames of a <link
linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link></refpurpose>
</refnamediv>
<refsect1>
<title>Synopsis</title>
<classsynopsis language="python">
<ooclass><classname>gtk.gdk.PixbufAnimationIter</classname></ooclass>
<ooclass><classname><link
linkend="class-gobject">gobject.GObject</link></classname></ooclass>
<methodsynopsis language="python">
<methodname><link
linkend="method-gdkpixbufanimationiter--get-delay-time">get_delay_time</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gdkpixbufanimationiter--get-pixbuf">get_pixbuf</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gdkpixbufanimationiter--on-currently-loading-frame">on_currently_loading_frame</link></methodname>
<methodparam></methodparam> </methodsynopsis>
<methodsynopsis language="python">
<methodname><link
linkend="method-gdkpixbufanimationiter--advance">advance</link></methodname>
<methodparam><parameter
role="keyword">current_time</parameter>
<initializer>0.0</initializer></methodparam>
</methodsynopsis>
</classsynopsis>
</refsect1>
<refsect1>
<title>Ancestry</title>
<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
+-- <link linkend="class-gdkpixbufanimationiter">gtk.gdk.PixbufAnimationIter</link>
</synopsis>
</refsect1>
<refsect1>
<title>Description</title>
<para>A <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link>
is used to access the frames of a <link
linkend="class-gdkpixbufanimation"><classname>gtk.gdk.PixbufAnimation</classname></link>
at specified times. A <link
linkend="class-gdkpixbufanimationiter"><classname>gtk.gdk.PixbufAnimationIter</classname></link>
object is created using the <link
linkend="method-gdkpixbufanimation--get-iter"><methodname>gtk.gdk.PixbufAnimation.get_iter</methodname>()</link>
method. After creating an iterator, you should immediately display the
pixbuf returned by the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>get_pixbuf</methodname>()</link>
method. Then, you should install a timeout (with the <link
linkend="function-gobject--timeout-add"><methodname>gobject.timeout_add</methodname>()</link>()
function) or by some other mechanism ensure that you'll update the image
after the number of milliseconds specified by the <link
linkend="method-gdkpixbufanimationiter--get-delay-time"><methodname>get_delay_time</methodname>()</link>
method. Each time the image is updated, you should reinstall the timeout
with the new, possibly-changed delay time.</para>
<para>To update the image (i.e. possibly change the result of the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>get_pixbuf</methodname>()</link>
method to a new frame of the animation), call the <link
linkend="method-gdkpixbufanimationiter--advance"><methodname>advance</methodname>()</link>
method.</para>
<para>If you're using a <link
linkend="class-gdkpixbufloader"><classname>gtk.gdk.PixbufLoader</classname></link>,
in addition to updating the image after the delay time, you should also
update it whenever you receive the "area_updated" signal and the <link
linkend="method-gdkpixbufanimationiter--on-currently-loading-frame"><methodname>on_currently_loading_frame</methodname>()</link>
method returns <literal>True</literal>. In this case, the frame currently
being fed into the loader has received new data, so needs to be refreshed.
The delay time for a frame may also be modified after an "area_updated"
signal, for example if the delay time for a frame is encoded in the data
after the frame itself. So your timeout should be reinstalled after any
area_updated signal. A delay time of -1 is possible, indicating
"infinite."</para>
</refsect1>
<refsect1>
<title>Methods</title>
<refsect2 id="method-gdkpixbufanimationiter--get-delay-time">
<title>gtk.gdk.PixbufAnimationIter.get_delay_time</title>
<programlisting><methodsynopsis language="python">
<methodname>get_delay_time</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the delay time in milliseconds (thousandths of
a second)</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_delay_time</methodname>() method returns the
number of milliseconds the current pixbuf should be displayed, or -1 if the
current pixbuf should be displayed forever. The <link
linkend="function-gobject--timeout-add"><methodname>gobject.timeout_add</methodname>()</link>()
function conveniently takes a timeout in milliseconds, so you can use a
timeout to schedule the next update.</para>
</refsect2>
<refsect2 id="method-gdkpixbufanimationiter--get-pixbuf">
<title>gtk.gdk.PixbufAnimationIter.get_pixbuf</title>
<programlisting><methodsynopsis language="python">
<methodname>get_pixbuf</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara>the current <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link> to be
displayed</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>get_pixbuf</methodname>() method returns the
current <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link> that
should be displayed. The pixbuf will be the same size as the animation
itself (see the <link
linkend="method-gdkpixbufanimation--get-width"><methodname>gtk.gdk.PixbufAnimation.get_width</methodname>()</link>
and <link
linkend="method-gdkpixbufanimation--get-height"><methodname>gtk.gdk.PixbufAnimation.get_height</methodname>()</link>
methods). The <link
linkend="class-gdkpixbuf"><classname>gtk.gdk.Pixbuf</classname></link>
should be displayed for the number of milliseconds specified by the <link
linkend="method-gdkpixbufanimationiter--get-delay-time"><methodname>get_delay_time</methodname>()</link>
method.</para>
</refsect2>
<refsect2 id="method-gdkpixbufanimationiter--on-currently-loading-frame">
<title>gtk.gdk.PixbufAnimationIter.on_currently_loading_frame</title>
<programlisting><methodsynopsis language="python">
<methodname>on_currently_loading_frame</methodname>
<methodparam></methodparam> </methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara><literal>True</literal> if the frame we're on
is partially loaded, or the last frame</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>on_currently_loading_frame</methodname>() method
returns <literal>True</literal> if the frame currently pointed to by the
iterator is partially loaded or the last frame. This method is used to
determine how to respond to the "area_updated" signal on <link
linkend="class-gdkpixbufloader"><classname>gtk.gdk.PixbufLoader</classname></link>
when loading an animation. The "area_updated" signal is emitted for an area
of the frame currently streaming in to the loader. So if you're on the
currently loading frame, you need to redraw the screen for the updated
area.</para>
</refsect2>
<refsect2 id="method-gdkpixbufanimationiter--advance">
<title>gtk.gdk.PixbufAnimationIter.advance</title>
<programlisting><methodsynopsis language="python">
<methodname>advance</methodname>
<methodparam><parameter role="keyword">current_time</parameter>
<initializer>0.0</initializer></methodparam>
</methodsynopsis></programlisting>
<variablelist>
<varlistentry>
<term><parameter
role="keyword">current_time</parameter> :</term>
<listitem><simpara>the current time as a float or 0.0 to
automatically determine the current time</simpara></listitem>
</varlistentry>
<varlistentry>
<term><emphasis>Returns</emphasis> :</term>
<listitem><simpara><literal>True</literal> if the image may need
updating</simpara></listitem>
</varlistentry>
</variablelist>
<para>The <methodname>advance</methodname>() method attempts to
advance an animation to a new frame. The frame is chosen based on the start
time passed to the <link
linkend="method-gdkpixbufanimation--get-iter"><methodname>gtk.gdk.PixbufAnimation.get_iter</methodname>()</link>
method. <parameter>current_time</parameter> is normally the current time (as
specified by the Python time.time() function) and must be greater than or
equal to the time passed to the <link
linkend="method-gdkpixbufanimation--get-iter"><methodname>gtk.gdk.PixbufAnimation.get_iter</methodname>()</link>
method, and must increase or remain unchanged each time the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>get_pixbuf</methodname>()</link>
method is called. That is, you can't go backward in time; animations only
play forward. As a shortcut, pass 0.0 (the default) for the current time and
the current time will automatically be determined an used. So you only need
to explicitly pass <parameter>current_time</parameter> if you're doing
something odd like playing the animation at double speed.</para>
<para>If this method returns <literal>False</literal>, there's no need
to update the animation display, assuming the display had been rendered
prior to advancing; if <literal>True</literal>, you need to call the <link
linkend="method-gdkpixbufanimationiter--get-pixbuf"><methodname>get_pixbuf</methodname>()</link>
method and update the display with the new pixbuf.</para>
</refsect2>
</refsect1>
</refentry>
|