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  _xoffset(0),
44  _yoffset(0)
45  {
46  }
47 
48  bool isLockCentered() const {
49  return _lock_centered;
50  }
51 
56  void setOffset(std::int32_t x, std::int32_t y) {
57  _xoffset = x;
58  _yoffset = y;
59  }
60 
61  std::int32_t xOffset() const { return _xoffset; }
62  std::int32_t yOffset() const { return _yoffset; }
63 
64  bool hasBounds() const {
65  return _bounds ? true : false;
66  }
67 
71  //
79  const SWFRect& getBounds() const { return *_bounds; }
80 
84  //
88  void setBounds(const SWFRect& bounds) {
89  _bounds = bounds;
90  }
91 
94  return _displayObject;
95  }
96 
98  void reset() {
99  _displayObject = nullptr;
100  _bounds.reset();
101  _lock_centered = false;
102  }
103 
105  void markReachableResources() const {
106  if (_displayObject) _displayObject->setReachable();
107  }
108 
109 private:
110 
113  boost::optional<SWFRect> _bounds;
114 
115  DisplayObject* _displayObject;
116 
117  bool _lock_centered;
118 
123  std::int32_t _xoffset;
124  std::int32_t _yoffset;
125 
126 };
127 
128 
129 } // namespace gnash
130 
131 #endif // GNASH_DRAG_STATE_H
void setReachable() const
Mark this resource as being reachable.
Definition: GC.h:92
Definition: GnashKey.h:150
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
DragState(DisplayObject *d, bool lock)
Definition: DragState.h:39
std::int32_t yOffset() const
Definition: DragState.h:62
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:88
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
bool isLockCentered() const
Definition: DragState.h:48
std::int32_t xOffset() const
Definition: DragState.h:61
bool hasBounds() const
Definition: DragState.h:64
std::int32_t x
Definition: BitmapData_as.cpp:434
DisplayObject * getCharacter() const
May return NULL !!
Definition: DragState.h:93
const SWFRect & getBounds() const
Get the boundaries to constraint the drag into.
Definition: DragState.h:79
void markReachableResources() const
Mark DisplayObject as reachable (if any)
Definition: DragState.h:105
void reset()
Reset drag state to its initial condition.
Definition: DragState.h:98
std::int32_t y
Definition: BitmapData_as.cpp:435
Rectangle class, see swf defined rectangle record.
Definition: SWFRect.h:44
void setOffset(std::int32_t x, std::int32_t y)
Definition: DragState.h:56