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
)
48 bool isLockCentered() const {
49 return _lock_centered
;
52 /// Set displacement offset from origin
53 /// at time of drag start.
54 /// Coordinates are in stage space (twips)
56 void setOffset(std::int32_t x
, std::int32_t y
) {
61 std::int32_t xOffset() const { return _xoffset
; }
62 std::int32_t yOffset() const { return _yoffset
; }
64 bool hasBounds() const {
65 return _bounds
? true : false;
69 /// Get the boundaries to constraint
72 /// Coordinates of the rectangle are
73 /// expected in TWIPS.
75 /// Note that if hasBounds() is false
76 /// the returned rectangle is the NULL
77 /// rectangle - see SWFRect::is_null().
79 const SWFRect
& getBounds() const { return *_bounds
; }
82 /// Set the boundaries to constraint
85 /// Coordinates of the rectangle are
86 /// expected in TWIPS.
88 void setBounds(const SWFRect
& bounds
) {
92 /// May return NULL !!
93 DisplayObject
* getCharacter() const {
94 return _displayObject
;
97 /// Reset drag state to its initial condition
99 _displayObject
= nullptr;
101 _lock_centered
= false;
104 /// Mark DisplayObject as reachable (if any)
105 void markReachableResources() const {
106 if (_displayObject
) _displayObject
->setReachable();
111 /// Boundaries to constrain the drag into.
112 /// Coordinates in TWIPS.
113 boost::optional
<SWFRect
> _bounds
;
115 DisplayObject
* _displayObject
;
119 /// Offsets of displacement from DisplayObject origin
120 /// at time of drag start. These are used for non
121 /// lock-centered dragging.
122 /// Coordinates are in stage space (TWIPS)
123 std::int32_t _xoffset
;
124 std::int32_t _yoffset
;
131 #endif // GNASH_DRAG_STATE_H