copy/paste caused some issues here
[swfdec.git] / libswfdec / swfdec_player_internal.h
blob182acd063a5582129d733906cd6eee30d123c709
1 /* Swfdec
2 * Copyright (C) 2006-2007 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifndef _SWFDEC_PLAYER_INTERNAL_H_
21 #define _SWFDEC_PLAYER_INTERNAL_H_
23 #include <libswfdec/swfdec_player.h>
24 #include <libswfdec/swfdec_as_context.h>
25 #include <libswfdec/swfdec_audio.h>
26 #include <libswfdec/swfdec_rect.h>
27 #include <libswfdec/swfdec_ringbuffer.h>
28 #include <libswfdec/swfdec_system.h>
30 G_BEGIN_DECLS
32 typedef enum {
33 SWFDEC_ALIGN_FLAG_TOP = (1 << 0),
34 SWFDEC_ALIGN_FLAG_BOTTOM = (1 << 1),
35 SWFDEC_ALIGN_FLAG_LEFT = (1 << 2),
36 SWFDEC_ALIGN_FLAG_RIGHT = (1 << 3)
37 } SwfdecAlignFlag;
39 typedef void (* SwfdecActionFunc) (gpointer object, gpointer data);
40 typedef gboolean (* SwfdecAudioRemoveFunc) (SwfdecAudio *audio, gpointer data);
42 typedef struct _SwfdecTimeout SwfdecTimeout;
43 struct _SwfdecTimeout {
44 SwfdecTick timestamp; /* timestamp at which this thing is supposed to trigger */
45 void (* callback) (SwfdecTimeout *advance);
46 void (* free) (SwfdecTimeout *advance);
49 struct _SwfdecPlayer
51 SwfdecAsContext context;
53 /* global properties */
54 SwfdecSystem * system; /* our system properties */
55 gboolean initialized; /* if width and height are set already */
56 guint rate; /* divide by 256 to get iterations per second */
57 guint width; /* width of movie */
58 guint height; /* height of movie */
59 GList * roots; /* all the root movies */
60 GList * load_objects; /* all the load objects */
61 SwfdecCache * cache; /* player cache */
62 gboolean bgcolor_set; /* TRUE if the background color has been set */
63 SwfdecColor bgcolor; /* background color */
64 SwfdecLoader * loader; /* initial loader */
65 /* stage properties */
66 guint internal_width; /* width used by the scripting engine */
67 guint internal_height; /* height used by the scripting engine */
68 gint stage_width; /* width set by the user */
69 gint stage_height; /* height set by the user */
70 SwfdecRectangle stage; /* size of the stage set by user */
71 guint align_flags; /* SwfdecAlignFlag */
72 SwfdecScaleMode scale_mode; /* scale mode */
73 double scale_x; /* cached x scale value */
74 double scale_y; /* cached y scale value */
75 int offset_x; /* x offset from top left edge after scaling */
76 int offset_y; /* y offset from top left edge after scaling */
77 gboolean xml_properties_initialized; /* whether XML object's native properties have been initialized */
78 gboolean xml_node_properties_initialized; /* same for XMLNode */
80 guint unnamed_count; /* variable used for naming unnamed movies */
81 /* ActionScript */
82 guint interval_id; /* id returned from setInterval call */
83 GList * intervals; /* all currently running intervals */
84 GHashTable * registered_classes; /* name => SwfdecAsObject constructor */
85 SwfdecAsObject * MovieClip; /* MovieClip object */
86 SwfdecAsObject * Video; /* Video object */
88 /* rendering */
89 SwfdecRectangle invalid_extents; /* extents of area that needs a redraw in global coordinates */
90 GArray * invalidations; /* fine-grained areas in need of redraw */
92 /* mouse */
93 gboolean mouse_visible; /* show the mouse (actionscriptable) */
94 SwfdecMouseCursor mouse_cursor; /* cursor that should be shown */
95 double mouse_x; /* in stage coordinates */
96 double mouse_y; /* in stage coordinates */
97 int mouse_button; /* 0 for not pressed, 1 for pressed */
98 SwfdecMovie * mouse_grab; /* movie that currently has the mouse */
99 SwfdecMovie * mouse_drag; /* current movie activated by startDrag */
100 gboolean mouse_drag_center; /* TRUE to use center of movie at mouse, FALSE for movie's (0,0) */
101 SwfdecRect mouse_drag_rect; /* clipping rectangle for movements */
102 double mouse_drag_x; /* offset of mouse in x direction */
103 double mouse_drag_y; /* offset of mouse in y direction */
105 /* key */
106 guint last_keycode; /* last keycode that was pressed/released */
107 guint last_character; /* UCS4 of last character pressed/released */
108 guint8 key_pressed[256/8]; /* boolean array for isDown */
110 /* audio */
111 GList * audio; /* list of playing SwfdecAudio */
113 /* events and advancing */
114 SwfdecTick time; /* current time */
115 GList * timeouts; /* list of events, sorted by timestamp */
116 guint tick; /* next tick */
117 SwfdecTimeout iterate_timeout; /* callback for iterating */
118 /* iterating */
119 GList * movies; /* list of all moveis that want to be iterated */
120 SwfdecRingBuffer * actions; /* all actions we've queued up so far */
121 SwfdecRingBuffer * external_actions; /* external actions we've queued up, like resize or loader stuff */
122 SwfdecTimeout external_timeout; /* callback for iterating */
123 GQueue * init_queue; /* all movies that require an init event */
124 GQueue * construct_queue; /* all movies that require an construct event */
127 struct _SwfdecPlayerClass
129 SwfdecAsContextClass context_class;
131 void (* advance) (SwfdecPlayer * player,
132 gulong msecs,
133 guint audio_samples);
134 gboolean (* handle_key) (SwfdecPlayer * player,
135 guint key,
136 guint character,
137 gboolean down);
138 gboolean (* handle_mouse) (SwfdecPlayer * player,
139 double x,
140 double y,
141 int button);
144 void swfdec_player_initialize (SwfdecPlayer * player,
145 guint version,
146 guint rate,
147 guint width,
148 guint height);
149 void swfdec_player_add_movie (SwfdecPlayer * player,
150 guint depth,
151 const char * url);
152 void swfdec_player_remove_movie (SwfdecPlayer * player,
153 SwfdecMovie * movie);
155 void swfdec_player_lock (SwfdecPlayer * player);
156 void swfdec_player_lock_soft (SwfdecPlayer * player);
157 void swfdec_player_unlock (SwfdecPlayer * player);
158 void swfdec_player_unlock_soft (SwfdecPlayer * player);
159 void swfdec_player_perform_actions (SwfdecPlayer * player);
161 SwfdecAsObject *swfdec_player_get_export_class (SwfdecPlayer * player,
162 const char * name);
163 void swfdec_player_set_export_class (SwfdecPlayer * player,
164 const char * name,
165 SwfdecAsObject * object);
167 void swfdec_player_invalidate (SwfdecPlayer * player,
168 const SwfdecRect * rect);
169 void swfdec_player_add_timeout (SwfdecPlayer * player,
170 SwfdecTimeout * timeout);
171 void swfdec_player_remove_timeout (SwfdecPlayer * player,
172 SwfdecTimeout * timeout);
173 void swfdec_player_add_external_action
174 (SwfdecPlayer * player,
175 gpointer object,
176 SwfdecActionFunc action_func,
177 gpointer action_data);
178 void swfdec_player_remove_all_external_actions
179 (SwfdecPlayer * player,
180 gpointer object);
181 void swfdec_player_add_action (SwfdecPlayer * player,
182 gpointer object,
183 SwfdecActionFunc action_func,
184 gpointer action_data);
185 void swfdec_player_remove_all_actions (SwfdecPlayer * player,
186 gpointer object);
188 void swfdec_player_set_drag_movie (SwfdecPlayer * player,
189 SwfdecMovie * drag,
190 gboolean center,
191 SwfdecRect * rect);
192 void swfdec_player_set_align_flags (SwfdecPlayer * player,
193 guint flags);
194 void swfdec_player_stop_sounds (SwfdecPlayer * player,
195 SwfdecAudioRemoveFunc func,
196 gpointer data);
197 void swfdec_player_stop_all_sounds (SwfdecPlayer * player);
198 SwfdecMovie * swfdec_player_add_level_from_loader
199 (SwfdecPlayer * player,
200 guint depth,
201 SwfdecLoader * loader,
202 const char * variables);
203 void swfdec_player_remove_level (SwfdecPlayer * player,
204 guint depth);
205 SwfdecLoader * swfdec_player_load (SwfdecPlayer * player,
206 const char * url);
207 void swfdec_player_launch (SwfdecPlayer * player,
208 const char * url,
209 const char * target);
210 void swfdec_player_stage_to_global (SwfdecPlayer * player,
211 double * x,
212 double * y);
213 void swfdec_player_global_to_stage (SwfdecPlayer * player,
214 double * x,
215 double * y);
216 /* in swfdec_as_interpret.c */
217 SwfdecMovie * swfdec_player_get_movie_from_value
218 (SwfdecPlayer * player,
219 SwfdecAsValue * val);
222 G_END_DECLS
223 #endif