update copyright date
[gnash.git] / libcore / MorphShape.h
blob577b62fd7c7c44a9311b1adf54b61aac3f506c83
1 // MorphShape.h: the MorphShape DisplayObject implementation for Gnash.
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
4 // 2011 Free Software Foundation, Inc
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef GNASH_MORPH_SHAPE_H
21 #define GNASH_MORPH_SHAPE_H
23 #include "smart_ptr.h"
24 #include "DisplayObject.h"
25 #include "swf/DefineMorphShapeTag.h"
26 #include <boost/intrusive_ptr.hpp>
27 #include <cassert>
29 namespace gnash {
30 class Renderer;
33 namespace gnash {
35 /// A DisplayObject that tweens between two shapes.
37 /// A MorphShape has no properties of its own, but its inherited properties
38 /// may be read in AS3 using a reference to the object created with
39 /// getChildAt().
41 /// Morphing is controlled using a SWF::PlaceObject2 tag with a ratio flag.
42 /// The most common and efficient way is to combine this with a move flag,
43 /// so that this object is moved to the position specified by the ratio.
44 /// However, it is also possible to remove and replace, in which case a
45 /// new MorphShape is created.
47 /// The starting position is not necessarily identical with shape1, though in
48 /// practice it often is.
49 class MorphShape : public DisplayObject
52 public:
54 MorphShape(movie_root& mr, as_object* object,
55 const SWF::DefineMorphShapeTag* def, DisplayObject* parent);
57 virtual void display(Renderer& renderer, const Transform& xform);
59 virtual SWFRect getBounds() const;
61 virtual bool pointInShape(boost::int32_t x, boost::int32_t y) const;
63 const SWF::ShapeRecord& shape() const {
64 return _shape;
67 private:
69 void morph();
71 double currentRatio() const;
73 const boost::intrusive_ptr<const SWF::DefineMorphShapeTag> _def;
75 SWF::ShapeRecord _shape;
80 } // namespace gnash
83 #endif
86 // Local Variables:
87 // mode: C++
88 // indent-tabs-mode: t
89 // End: