Oxygine  1
2g game engine
Draggable.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "Actor.h"
4 //#include "Event.h"
5 
6 namespace oxygine
7 {
8  Vector2 convertPosUp(Actor* src, Actor* dest, const Vector2& pos, bool direction);
9  Vector2 convertPosDown(Actor* src, Actor* dest, const Vector2& pos, bool direction);
10 
11  class Draggable
12  {
13  public:
14  Draggable();
15  ~Draggable();
16 
17  void init(Actor* actor);
18  void start(const PointerState* pointer, Actor* actor, const Vector2& localCenter);
19 
20  void destroy();
21 
22  Actor* getDragClient() const {return _dragClient;}
23  const RectF& getDragBounds() const {return _bounds;}
24  const Vector2& getClientPos() const {return _clientPos;}
25  bool getDragEnabled() const { return _dragEnabled; }
26  bool isDragging() const {return _pressed;}
27 
28  void setDragEnabled(bool en) {_dragEnabled = en;}
30  void setDragBounds(const RectF& bounds);
32  void setDragClient(Actor* actor);
33  void setIgnoreTouchUp(bool ignore) { _ignoreTouchUp = ignore; }
34  void snapClient2Bounds();
35 
36  protected:
37  Actor* getClient();
38  void onEvent(Event* event);
39  void startDrag(const Vector2& localPos);
40 
41  void onDrag(TouchEvent* es);
42  void onMove(const Vector2& position);
43 
44  Actor* _dragClient;
45  Actor* _actor;
46  timeMS _startTm;
47  bool _singleDrag;
48 
49  RectF _bounds;
50  Vector2 _dragPos;
51  Vector2 _clientPos;
52 
53  bool _clientIsParent;
54  bool _pressed;
55  bool _dragEnabled;
56  bool _ignoreTouchUp;
57  };
58 }
Definition: Actor.h:42
Definition: Event.h:10
void setDragBounds(const RectF &bounds)
Definition: Draggable.h:11
void setDragClient(Actor *actor)
–oxgl-end–!
Definition: Actor.h:14
Definition: PointerState.h:18
Definition: TouchEvent.h:7