fix build for --disable-gtk-doc
[swfdec.git] / swfdec / swfdec_graphic_movie.c
blobf5e31378a9b94c8224db8afa7d5e3e25ed6836ec
1 /* Swfdec
2 * Copyright (C) 2006 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 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include "swfdec_graphic_movie.h"
25 #include "swfdec_button.h"
26 #include "swfdec_debug.h"
27 #include "swfdec_movie.h"
28 #include "swfdec_player_internal.h"
29 #include "swfdec_shape.h"
30 #include "swfdec_sprite.h"
31 #include "swfdec_swf_decoder.h"
32 #include "swfdec_resource.h"
33 #include "swfdec_text.h"
34 #include "swfdec_text_field.h"
36 G_DEFINE_TYPE (SwfdecGraphicMovie, swfdec_graphic_movie, SWFDEC_TYPE_MOVIE)
38 static void
39 swfdec_graphic_movie_update_extents (SwfdecMovie *movie,
40 SwfdecRect *extents)
42 swfdec_rect_union (extents, extents,
43 &movie->graphic->extents);
46 static void
47 swfdec_graphic_movie_render (SwfdecMovie *movie, cairo_t *cr,
48 const SwfdecColorTransform *trans)
50 swfdec_graphic_render (movie->graphic, cr, trans);
53 static void
54 swfdec_graphic_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
56 SwfdecRect rect;
58 swfdec_rect_transform (&rect, &movie->graphic->extents, matrix);
59 swfdec_player_invalidate (SWFDEC_PLAYER (swfdec_gc_object_get_context (movie)),
60 movie, &rect);
63 static SwfdecMovie *
64 swfdec_graphic_movie_contains (SwfdecMovie *movie, double x, double y,
65 gboolean events)
67 if (swfdec_graphic_mouse_in (movie->graphic, x, y))
68 return movie;
69 else
70 return NULL;
73 static void
74 swfdec_graphic_movie_replace (SwfdecMovie *movie, SwfdecGraphic *graphic)
76 if (SWFDEC_IS_SHAPE (graphic) ||
77 SWFDEC_IS_TEXT (graphic)) {
78 /* nothing to do here, please move along */
79 } else if (SWFDEC_IS_SPRITE (graphic) ||
80 SWFDEC_IS_BUTTON (graphic) ||
81 SWFDEC_IS_TEXT_FIELD (graphic)) {
82 SWFDEC_INFO ("can't replace with scriptable objects");
83 return;
84 } else {
85 SWFDEC_FIXME ("Can we replace with %s objects?", G_OBJECT_TYPE_NAME (graphic));
86 return;
88 if (movie->graphic == graphic)
89 return;
90 swfdec_movie_invalidate_next (movie);
91 SWFDEC_LOG ("replacing %u with %u", SWFDEC_CHARACTER (movie->graphic)->id,
92 SWFDEC_CHARACTER (graphic)->id);
93 swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_EXTENTS);
94 g_object_unref (movie->graphic);
95 movie->graphic = g_object_ref (graphic);
98 static void
99 swfdec_graphic_movie_class_init (SwfdecGraphicMovieClass * g_class)
101 SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
103 movie_class->update_extents = swfdec_graphic_movie_update_extents;
104 movie_class->replace = swfdec_graphic_movie_replace;
105 movie_class->render = swfdec_graphic_movie_render;
106 movie_class->invalidate = swfdec_graphic_movie_invalidate;
107 movie_class->contains = swfdec_graphic_movie_contains;
110 static void
111 swfdec_graphic_movie_init (SwfdecGraphicMovie * graphic_movie)