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  * Conversion parameters:
26  * inFile  = gdk3-GdkFrameClock.html
27  * outPack = gdk
28  * outFile = FrameClock
29  * strct   = GdkFrameClock
30  * realStrct=
31  * ctorStrct=
32  * clss    = FrameClock
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_frame_clock_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gdk.FrameTimings
47  * structWrap:
48  * 	- GdkFrameTimings* -> FrameTimings
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gdk.FrameClock;
55 
56 public  import gtkc.gdktypes;
57 
58 private import gtkc.gdk;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 
63 private import gdk.FrameTimings;
64 
65 
66 
67 
68 /**
69  * A GdkFrameClock tells the application when to update and repaint a
70  * window. This may be synced to the vertical refresh rate of the
71  * monitor, for example. Even when the frame clock uses a simple timer
72  * rather than a hardware-based vertical sync, the frame clock helps
73  * because it ensures everything paints at the same time (reducing the
74  * total number of frames). The frame clock can also automatically
75  * stop painting when it knows the frames will not be visible, or
76  * scale back animation framerates.
77  *
78  * GdkFrameClock is designed to be compatible with an OpenGL-based
79  * implementation or with mozRequestAnimationFrame in Firefox,
80  * for example.
81  *
82  * A frame clock is idle until someone requests a frame with
83  * gdk_frame_clock_request_phase(). At some later point that makes
84  * sense for the synchronization being implemented, the clock will
85  * process a frame and emit signals for each phase that has been
86  * requested. (See the signals of the GdkFrameClock class for
87  * documentation of the phases. GDK_FRAME_CLOCK_PHASE_UPDATE and the
88  * "update" signal are most interesting for application
89  * writers, and are used to update the animations, using the frame time
90  * given by gdk_frame_clock_get_frame_time().
91  *
92  * The frame time is reported in microseconds and generally in the same
93  * timescale as g_get_monotonic_time(), however, it is not the same
94  * as g_get_monotonic_time(). The frame time does not advance during
95  * the time a frame is being painted, and outside of a frame, an attempt
96  * is made so that all calls to gdk_frame_clock_get_frame_time() that
97  * are called at a "similar" time get the same value. This means that
98  * if different animations are timed by looking at the difference in
99  * time between an initial value from gdk_frame_clock_get_frame_time()
100  * and the value inside the "update" signal of the clock,
101  * they will stay exactly synchronized.
102  */
103 public class FrameClock
104 {
105 	
106 	/** the main Gtk struct */
107 	protected GdkFrameClock* gdkFrameClock;
108 	
109 	
110 	public GdkFrameClock* getFrameClockStruct()
111 	{
112 		return gdkFrameClock;
113 	}
114 	
115 	
116 	/** the main Gtk struct as a void* */
117 	protected void* getStruct()
118 	{
119 		return cast(void*)gdkFrameClock;
120 	}
121 	
122 	/**
123 	 * Sets our main struct and passes it to the parent class
124 	 */
125 	public this (GdkFrameClock* gdkFrameClock)
126 	{
127 		this.gdkFrameClock = gdkFrameClock;
128 	}
129 	
130 	/**
131 	 */
132 	
133 	/**
134 	 * Gets the time that should currently be used for animations. Inside
135 	 * the processing of a frame, it's the time used to compute the
136 	 * animation position of everything in a frame. Outside of a frame, it's
137 	 * the time of the conceptual "previous frame," which may be either
138 	 * the actual previous frame time, or if that's too old, an updated
139 	 * time.
140 	 * Returns: a timestamp in microseconds, in the timescale of of g_get_monotonic_time(). Since 3.8
141 	 */
142 	public long getFrameTime()
143 	{
144 		// gint64 gdk_frame_clock_get_frame_time (GdkFrameClock *frame_clock);
145 		return gdk_frame_clock_get_frame_time(gdkFrameClock);
146 	}
147 	
148 	/**
149 	 * Asks the frame clock to run a particular phase. The signal
150 	 * corresponding the requested phase will be emitted the next
151 	 * time the frame clock processes. Multiple calls to
152 	 * gdk_frame_clock_request_phase() will be combined together
153 	 * and only one frame processed. If you are displaying animated
154 	 * content and want to continually request the
155 	 * GDK_FRAME_CLOCK_PHASE_UPDATE phase for a period of time,
156 	 * you should use gdk_frame_clock_begin_updating() instead, since
157 	 * this allows GTK+ to adjust system parameters to get maximally
158 	 * smooth animations.
159 	 * Params:
160 	 * phase = the phase that is requested
161 	 * Since 3.8
162 	 */
163 	public void requestPhase(GdkFrameClockPhase phase)
164 	{
165 		// void gdk_frame_clock_request_phase (GdkFrameClock *frame_clock,  GdkFrameClockPhase phase);
166 		gdk_frame_clock_request_phase(gdkFrameClock, phase);
167 	}
168 	
169 	/**
170 	 * Starts updates for an animation. Until a matching call to
171 	 * gdk_frame_clock_end_updating() is made, the frame clock will continually
172 	 * request a new frame with the GDK_FRAME_CLOCK_PHASE_UPDATE phase.
173 	 * This function may be called multiple times and frames will be
174 	 * requested until gdk_frame_clock_end_updating() is called the same
175 	 * number of times.
176 	 */
177 	public void beginUpdating()
178 	{
179 		// void gdk_frame_clock_begin_updating (GdkFrameClock *frame_clock);
180 		gdk_frame_clock_begin_updating(gdkFrameClock);
181 	}
182 	
183 	/**
184 	 * Stops updates for an animation. See the documentation for
185 	 * gdk_frame_clock_begin_updating().
186 	 */
187 	public void endUpdating()
188 	{
189 		// void gdk_frame_clock_end_updating (GdkFrameClock *frame_clock);
190 		gdk_frame_clock_end_updating(gdkFrameClock);
191 	}
192 	
193 	/**
194 	 * A GdkFrameClock maintains a 64-bit counter that increments for
195 	 * each frame drawn.
196 	 * Returns: inside frame processing, the value of the frame counter for the current frame. Outside of frame processing, the frame counter for the last frame. Since 3.8
197 	 */
198 	public long getFrameCounter()
199 	{
200 		// gint64 gdk_frame_clock_get_frame_counter (GdkFrameClock *frame_clock);
201 		return gdk_frame_clock_get_frame_counter(gdkFrameClock);
202 	}
203 	
204 	/**
205 	 * GdkFrameClock internally keeps a history of GdkFrameTiming
206 	 * objects for recent frames that can be retrieved with
207 	 * gdk_frame_clock_get_timings(). The set of stored frames
208 	 * is the set from the counter values given by
209 	 * gdk_frame_clock_get_history_start() and
210 	 * gdk_frame_clock_get_frame_counter(), inclusive.
211 	 * Returns: the frame counter value for the oldest frame that is available in the internal frame history of the GdkFrameClock. Since 3.8
212 	 */
213 	public long getHistoryStart()
214 	{
215 		// gint64 gdk_frame_clock_get_history_start (GdkFrameClock *frame_clock);
216 		return gdk_frame_clock_get_history_start(gdkFrameClock);
217 	}
218 	
219 	/**
220 	 * Retrieves a GdkFrameTimings object holding timing information
221 	 * for the current frame or a recent frame. The GdkFrameTimings
222 	 * object may not yet be complete: see gdk_frame_timings_get_complete().
223 	 * Params:
224 	 * frameCounter = the frame counter value identifying the frame to
225 	 * be received.
226 	 * Returns: the GdkFrameTimings object for the specified frame, or NULL if it is not available. See gdk_frame_clock_get_history_start(). Since 3.8
227 	 */
228 	public FrameTimings getTimings(long frameCounter)
229 	{
230 		// GdkFrameTimings * gdk_frame_clock_get_timings (GdkFrameClock *frame_clock,  gint64 frame_counter);
231 		auto p = gdk_frame_clock_get_timings(gdkFrameClock, frameCounter);
232 		
233 		if(p is null)
234 		{
235 			return null;
236 		}
237 		
238 		return ObjectG.getDObject!(FrameTimings)(cast(GdkFrameTimings*) p);
239 	}
240 	
241 	/**
242 	 * Gets the frame timings for the current frame.
243 	 * Returns: the GdkFrameTimings for the frame currently being processed, or even no frame is being processed, for the previous frame. Before any frames have been procesed, returns NULL. Since 3.8
244 	 */
245 	public FrameTimings getCurrentTimings()
246 	{
247 		// GdkFrameTimings * gdk_frame_clock_get_current_timings (GdkFrameClock *frame_clock);
248 		auto p = gdk_frame_clock_get_current_timings(gdkFrameClock);
249 		
250 		if(p is null)
251 		{
252 			return null;
253 		}
254 		
255 		return ObjectG.getDObject!(FrameTimings)(cast(GdkFrameTimings*) p);
256 	}
257 	
258 	/**
259 	 * Using the frame history stored in the frame clock, finds the last
260 	 * known presentation time and refresh interval, and assuming that
261 	 * presentation times are separated by the refresh interval,
262 	 * predicts a presentation time that is a multiple of the refresh
263 	 * interval after the last presentation time, and later than base_time.
264 	 * Params:
265 	 * baseTime = base time for determining a presentaton time
266 	 * refreshIntervalReturn = a location to store the determined refresh
267 	 * interval, or NULL. A default refresh interval of 1/60th of
268 	 * a second will be stored if no history is present.
269 	 * presentationTimeReturn = a location to store the next
270 	 * candidate presentation time after the given base time.
271 	 * 0 will be will be stored if no history is present.
272 	 * Since 3.8
273 	 */
274 	public void getRefreshInfo(long baseTime, out long refreshIntervalReturn, out long presentationTimeReturn)
275 	{
276 		// void gdk_frame_clock_get_refresh_info (GdkFrameClock *frame_clock,  gint64 base_time,  gint64 *refresh_interval_return,  gint64 *presentation_time_return);
277 		gdk_frame_clock_get_refresh_info(gdkFrameClock, baseTime, &refreshIntervalReturn, &presentationTimeReturn);
278 	}
279 }