don't use CROSS_FLAGS for executables, as -all-staic prevents Android from looking...
[gnash.git] / libcore / DragState.h
blob7bdc87096b3fb2c90e860abe13c9723bb5604b3a
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program 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 General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef GNASH_DRAG_STATE_H
20 #define GNASH_DRAG_STATE_H
22 #include <boost/optional.hpp>
24 #include "SWFRect.h"
25 #include "DisplayObject.h"
27 // Forward declarations
28 namespace gnash {
29 class DisplayObject;
32 namespace gnash {
34 /// What is being dragged and how
35 class DragState
37 public:
39 DragState(DisplayObject* d, bool lock)
41 _displayObject(d),
42 _lock_centered(lock)
46 bool isLockCentered() const {
47 return _lock_centered;
50 /// Set displacement offset from origin
51 /// at time of drag start.
52 /// Coordinates are in stage space (twips)
53 ///
54 void setOffset(boost::int32_t x, boost::int32_t y) {
55 _xoffset = x;
56 _yoffset = y;
59 boost::int32_t xOffset() const { return _xoffset; }
60 boost::int32_t yOffset() const { return _yoffset; }
62 bool hasBounds() const {
63 return (_bounds);
66 /// \brief
67 /// Get the boundaries to constraint
68 /// the drag into.
70 /// Coordinates of the rectangle are
71 /// expected in TWIPS.
72 ///
73 /// Note that if hasBounds() is false
74 /// the returned rectangle is the NULL
75 /// rectangle - see SWFRect::is_null().
76 ///
77 const SWFRect& getBounds() const { return *_bounds; }
79 /// \brief
80 /// Set the boundaries to constraint
81 /// the drag into.
83 /// Coordinates of the rectangle are
84 /// expected in TWIPS.
85 ///
86 void setBounds(const SWFRect& bounds) {
87 _bounds = bounds;
90 /// May return NULL !!
91 DisplayObject* getCharacter() const {
92 return _displayObject;
95 /// Reset drag state to its initial condition
96 void reset() {
97 _displayObject = 0;
98 _bounds.reset();
99 _lock_centered = false;
102 /// Mark DisplayObject as reachable (if any)
103 void markReachableResources() const {
104 if (_displayObject) _displayObject->setReachable();
107 private:
109 /// Boundaries to constrain the drag into.
110 /// Coordinates in TWIPS.
111 boost::optional<SWFRect> _bounds;
113 DisplayObject* _displayObject;
115 bool _lock_centered;
117 /// Offsets of displacement from DisplayObject origin
118 /// at time of drag start. These are used for non
119 /// lock-centered dragging.
120 /// Coordinates are in stage space (TWIPS)
121 boost::int32_t _xoffset;
122 boost::int32_t _yoffset;
127 } // namespace gnash
129 #endif // GNASH_DRAG_STATE_H