Gnash  0.8.11dev
DragState.h
Go to the documentation of this file.
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
18 
19 #ifndef GNASH_DRAG_STATE_H
20 #define GNASH_DRAG_STATE_H
21 
22 #include <boost/optional.hpp>
23 
24 #include "SWFRect.h"
25 #include "DisplayObject.h"
26 
27 // Forward declarations
28 namespace gnash {
29  class DisplayObject;
30 }
31 
32 namespace gnash {
33 
35 class DragState
36 {
37 public:
38 
39  DragState(DisplayObject* d, bool lock)
40  :
41  _displayObject(d),
42  _lock_centered(lock)
43  {
44  }
45 
46  bool isLockCentered() const {
47  return _lock_centered;
48  }
49 
54  void setOffset(boost::int32_t x, boost::int32_t y) {
55  _xoffset = x;
56  _yoffset = y;
57  }
58 
59  boost::int32_t xOffset() const { return _xoffset; }
60  boost::int32_t yOffset() const { return _yoffset; }
61 
62  bool hasBounds() const {
63  return (_bounds);
64  }
65 
69  //
77  const SWFRect& getBounds() const { return *_bounds; }
78 
82  //
86  void setBounds(const SWFRect& bounds) {
87  _bounds = bounds;
88  }
89 
92  return _displayObject;
93  }
94 
96  void reset() {
97  _displayObject = 0;
98  _bounds.reset();
99  _lock_centered = false;
100  }
101 
103  void markReachableResources() const {
104  if (_displayObject) _displayObject->setReachable();
105  }
106 
107 private:
108 
111  boost::optional<SWFRect> _bounds;
112 
113  DisplayObject* _displayObject;
114 
115  bool _lock_centered;
116 
121  boost::int32_t _xoffset;
122  boost::int32_t _yoffset;
123 
124 };
125 
126 
127 } // namespace gnash
128 
129 #endif // GNASH_DRAG_STATE_H
Definition: GnashKey.h:150
bool hasBounds() const
Definition: DragState.h:62
boost::int32_t xOffset() const
Definition: DragState.h:59
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
DragState(DisplayObject *d, bool lock)
Definition: DragState.h:39
What is being dragged and how.
Definition: DragState.h:35
void setBounds(const SWFRect &bounds)
Set the boundaries to constraint the drag into.
Definition: DragState.h:86
void setOffset(boost::int32_t x, boost::int32_t y)
Definition: DragState.h:54
DisplayObject * getCharacter() const
May return NULL !!
Definition: DragState.h:91
bool isLockCentered() const
Definition: DragState.h:46
void markReachableResources() const
Mark DisplayObject as reachable (if any)
Definition: DragState.h:103
boost::int32_t x
Definition: BitmapData_as.cpp:434
const SWFRect & getBounds() const
Get the boundaries to constraint the drag into.
Definition: DragState.h:77
void setReachable() const
Mark this resource as being reachable.
Definition: GC.h:92
boost::int32_t yOffset() const
Definition: DragState.h:60
void reset()
Reset drag state to its initial condition.
Definition: DragState.h:96
boost::int32_t y
Definition: BitmapData_as.cpp:435
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44