EditorToyTool.cc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #include "console/consoleInternal.h"
  2. #include "console/console.h"
  3. #include "graphics/dgl.h"
  4. #include "2d/editorToy/EditorToyTool.h"
  5. //-----------------------------------------------------------------------
  6. IMPLEMENT_CONOBJECT(EditorToyTool);
  7. //-----------------------------------------------------------------------
  8. EditorToyTool::EditorToyTool()
  9. {
  10. mEditorToy = NULL;
  11. mUseMouseDown = true;
  12. mUseMouseUp = true;
  13. mUseMouseMove = true;
  14. mUseRightMouseDown = false;
  15. mUseRightMouseUp = false;
  16. mUseRightMouseMove = false;
  17. mUseMiddleMouseDown = true;
  18. mUseMiddleMouseUp = true;
  19. mUseMiddleMouseMove = true;
  20. mUseKeyInput = true;
  21. }
  22. EditorToyTool::~EditorToyTool()
  23. {
  24. }
  25. bool EditorToyTool::onAdd()
  26. {
  27. return Parent::onAdd();
  28. }
  29. void EditorToyTool::onRemove()
  30. {
  31. Parent::onRemove();
  32. }
  33. void EditorToyTool::onActivate(EditorToySceneWindow* sceneWin)
  34. {
  35. mEditorToy = sceneWin;
  36. Con::executef(this, 1, "onActivate");
  37. }
  38. void EditorToyTool::onDeactivate()
  39. {
  40. mEditorToy = NULL;
  41. Con::executef(this, 1, "onDeactivate");
  42. }
  43. void EditorToyTool::onRelinquishObj(SceneObject * obj)
  44. {
  45. }
  46. bool EditorToyTool::onTouchMove(const GuiEvent &e)
  47. {
  48. if (!mUseMouseDown)
  49. return false;
  50. Con::executef(this, 2, "onTouchMove", e.mousePoint);
  51. return true;
  52. }
  53. bool EditorToyTool::onTouchDown(const GuiEvent &e)
  54. {
  55. if (!mUseMouseDown)
  56. return false;
  57. Con::executef(this, 2, "onTouchDown", e.mousePoint);
  58. return true;
  59. }
  60. bool EditorToyTool::onTouchDragged(const GuiEvent &e)
  61. {
  62. Con::executef(this, 2, "onTouchDragged", e.mousePoint);
  63. return true;
  64. }
  65. bool EditorToyTool::onTouchUp(const GuiEvent &e)
  66. {
  67. if (!mUseMouseDown)
  68. return false;
  69. Con::executef(this, 2, "onTouchUp", e.mousePoint);
  70. return true;
  71. }
  72. bool EditorToyTool::onRightMouseDown(const GuiEvent &e)
  73. {
  74. if (!mUseRightMouseDown)
  75. return false;
  76. Con::executef(this,2, "onRightMouseDown", e.mousePoint);
  77. return true;
  78. }
  79. bool EditorToyTool::onRightMouseDragged(const GuiEvent &e)
  80. {
  81. Con::executef(this,2, "onRightMouseDragged", e.mousePoint);
  82. return true;
  83. }
  84. bool EditorToyTool::onRightMouseUp(const GuiEvent &e)
  85. {
  86. if (!mUseRightMouseDown)
  87. return false;
  88. Con::executef(this,2, "onRightMouseUp", e.mousePoint);
  89. return true;
  90. }
  91. bool EditorToyTool::onMiddleMouseDown(const GuiEvent &e)
  92. {
  93. if (!mUseMiddleMouseDown)
  94. return false;
  95. Con::executef(this,2, "onMiddleMouseDown", e.mousePoint);
  96. return true;
  97. }
  98. bool EditorToyTool::onMiddleMouseDragged(const GuiEvent &e)
  99. {
  100. Con::executef(this,2, "onMiddleMouseDragged", e.mousePoint);
  101. return true;
  102. }
  103. bool EditorToyTool::onMiddleMouseUp(const GuiEvent &e)
  104. {
  105. if (!mUseMiddleMouseDown)
  106. return false;
  107. Con::executef(this,2, "onMiddleMouseUp", e.mousePoint);
  108. return true;
  109. }
  110. bool EditorToyTool::onInputEvent(const GuiEvent &e)
  111. {
  112. if (!mUseKeyInput)
  113. return false;
  114. Con::executef(this,3, "onKeyPress", e.ascii, e.modifier);
  115. return true;
  116. }