2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
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.
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.
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>
25 #include "DisplayObject.h"
27 // Forward declarations
34 /// What is being dragged and how
39 DragState(DisplayObject
* d
, bool 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)
54 void setOffset(boost::int32_t x
, boost::int32_t y
) {
59 boost::int32_t xOffset() const { return _xoffset
; }
60 boost::int32_t yOffset() const { return _yoffset
; }
62 bool hasBounds() const {
67 /// Get the boundaries to constraint
70 /// Coordinates of the rectangle are
71 /// expected in TWIPS.
73 /// Note that if hasBounds() is false
74 /// the returned rectangle is the NULL
75 /// rectangle - see SWFRect::is_null().
77 const SWFRect
& getBounds() const { return *_bounds
; }
80 /// Set the boundaries to constraint
83 /// Coordinates of the rectangle are
84 /// expected in TWIPS.
86 void setBounds(const SWFRect
& bounds
) {
90 /// May return NULL !!
91 DisplayObject
* getCharacter() const {
92 return _displayObject
;
95 /// Reset drag state to its initial condition
99 _lock_centered
= false;
102 /// Mark DisplayObject as reachable (if any)
103 void markReachableResources() const {
104 if (_displayObject
) _displayObject
->setReachable();
109 /// Boundaries to constrain the drag into.
110 /// Coordinates in TWIPS.
111 boost::optional
<SWFRect
> _bounds
;
113 DisplayObject
* _displayObject
;
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
;
129 #endif // GNASH_DRAG_STATE_H