TDME2  1.9.200
DraggingScreenController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
6 #include <tdme/tdme.h>
11 
12 using std::string;
13 using std::unique_ptr;
14 
21 
22 /**
23  * Dragging screen controller
24  * @author Andreas Drewke
25  */
27  : public ScreenController
28  , public GUIMoveListener
29 {
30 
31 private:
32  GUIScreenNode* screenNode { nullptr };
34 
35  string payload;
36 
37  int dragReleaseMouseX { -1 };
38  int dragReleaseMouseY { -1 };
39 
40  unique_ptr<Action> onReleaseAction;
41 
42 public:
43  // forbid class copy
45 
46  /**
47  * Public constructor
48  */
50 
51  /**
52  * Destructor
53  */
54  virtual ~DraggingScreenController();
55 
56  /**
57  * @return current payload
58  */
59  inline const string& getPayload() {
60  return payload;
61  }
62 
63  /**
64  * @return unscaled drag release mouse X position
65  */
66  inline int getDragReleaseMouseX() {
67  return dragReleaseMouseX;
68  }
69 
70  /**
71  * @return unscaled drag release mouse Y position
72  */
73  inline int getDragReleaseMouseY() {
74  return dragReleaseMouseY;
75  }
76 
77  // overridden methods
78  GUIScreenNode* getScreenNode() override;
79  void initialize() override;
80  void dispose() override;
81  bool accept(GUINode* node) override;
82  void onMove(GUINode* node) override;
83  void onRelease(GUINode* node, int mouseX, int mouseY) override;
84 
85  /**
86  * Show dragging screen and a dragging image from given source
87  * @param mouseX mouse X
88  * @param mouseY mouse Y
89  * @param xml xml
90  * @param payload payload
91  * @param onReleaseAction on release action
92  */
93  void start(int mouseX, int mouseY, const string& xml, const string& payload, Action* onReleaseAction);
94 
95  /**
96  * Close dragging screen
97  */
98  void close();
99 
100 };
GUI node base class.
Definition: GUINode.h:64
GUI parent node base class thats supporting child nodes.
Definition: GUIParentNode.h:42
GUI screen node that represents a screen that can be rendered via GUI system.
Definition: GUIScreenNode.h:72
void start(int mouseX, int mouseY, const string &xml, const string &payload, Action *onReleaseAction)
Show dragging screen and a dragging image from given source.
void onRelease(GUINode *node, int mouseX, int mouseY) override
On release.
GUI move listener interface.
Screen controller, which connects GUI screen definition with code.
Action Interface.
Definition: Action.h:11
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6