Include program counter on action limit notification log
[gnash.git] / libcore / DragState.h
blobdb88eae449c3b45d33fd63e0f7c56db9e6a5b97c
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software
3 // 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 "SWFRect.h"
23 #include "DisplayObject.h"
25 // Forward declarations
26 namespace gnash {
27 class DisplayObject;
30 namespace gnash {
32 /// What is being dragged and how
33 class DragState
35 public:
37 DragState(DisplayObject* d)
39 _hasbounds(false),
40 _bounds(),
41 _displayObject(d),
42 _lock_centered(false)
46 bool isLockCentered() const {
47 return _lock_centered;
50 void setLockCentered(bool lock) {
51 _lock_centered = lock;
54 /// Set displacement offset from origin
55 /// at time of drag start.
56 /// Coordinates are in stage space (twips)
57 ///
58 void setOffset(boost::int32_t x, boost::int32_t y) {
59 _xoffset = x;
60 _yoffset = y;
63 boost::int32_t xOffset() const { return _xoffset; }
64 boost::int32_t yOffset() const { return _yoffset; }
66 bool hasBounds() const {
67 return _hasbounds;
70 /// \brief
71 /// Get the boundaries to constraint
72 /// the drag into.
74 /// Coordinates of the rectangle are
75 /// expected in TWIPS.
76 ///
77 /// Note that if hasBounds() is false
78 /// the returned rectangle is the NULL
79 /// rectangle - see SWFRect::is_null().
80 ///
81 const SWFRect& getBounds() const { return _bounds; }
83 /// \brief
84 /// Set the boundaries to constraint
85 /// the drag into.
87 /// Coordinates of the rectangle are
88 /// expected in TWIPS.
89 ///
90 void setBounds(const SWFRect& bounds) {
91 _bounds = bounds;
92 _hasbounds = true;
95 /// May return NULL !!
96 DisplayObject* getCharacter() const {
97 return _displayObject;
100 /// Reset drag state to its initial condition
101 void reset() {
102 _displayObject = 0;
103 _hasbounds = false;
104 _bounds.set_null();
105 _lock_centered = false;
108 /// Mark DisplayObject as reachable (if any)
109 void markReachableResources() const {
110 if (_displayObject) _displayObject->setReachable();
113 private:
115 bool _hasbounds;
117 /// Boundaries to constrain the drag into.
118 /// Coordinates in TWIPS.
119 SWFRect _bounds;
121 DisplayObject* _displayObject;
123 bool _lock_centered;
125 /// Offsets of displacement from DisplayObject origin
126 /// at time of drag start. These are used for non
127 /// lock-centered dragging.
128 /// Coordinates are in stage space (TWIPS)
129 boost::int32_t _xoffset;
130 boost::int32_t _yoffset;
135 } // namespace gnash
137 #endif // GNASH_DRAG_STATE_H