123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- #include "console/consoleInternal.h"
- #include "console/console.h"
- #include "graphics/dgl.h"
- #include "2d/editorToy/EditorToyTool.h"
- //-----------------------------------------------------------------------
- IMPLEMENT_CONOBJECT(EditorToyTool);
- //-----------------------------------------------------------------------
- EditorToyTool::EditorToyTool()
- {
- mEditorToy = NULL;
- mUseMouseDown = true;
- mUseMouseUp = true;
- mUseMouseMove = true;
- mUseRightMouseDown = false;
- mUseRightMouseUp = false;
- mUseRightMouseMove = false;
- mUseMiddleMouseDown = true;
- mUseMiddleMouseUp = true;
- mUseMiddleMouseMove = true;
- mUseKeyInput = true;
- }
- EditorToyTool::~EditorToyTool()
- {
- }
- bool EditorToyTool::onAdd()
- {
- return Parent::onAdd();
- }
- void EditorToyTool::onRemove()
- {
- Parent::onRemove();
- }
- void EditorToyTool::onActivate(EditorToySceneWindow* sceneWin)
- {
- mEditorToy = sceneWin;
- Con::executef(this, 1, "onActivate");
- }
- void EditorToyTool::onDeactivate()
- {
- mEditorToy = NULL;
- Con::executef(this, 1, "onDeactivate");
- }
- void EditorToyTool::onRelinquishObj(SceneObject * obj)
- {
- }
- bool EditorToyTool::onTouchMove(const GuiEvent &e)
- {
- if (mUseMouseDown && isMethod("onTouchMove"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onTouchMove", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onTouchDown(const GuiEvent &e)
- {
- if (mUseMouseDown && isMethod("onTouchDown"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onTouchDown", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onTouchDragged(const GuiEvent &e)
- {
- if (isMethod("onTouchDragged"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onTouchDragged", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onTouchUp(const GuiEvent &e)
- {
- if (mUseMouseDown && isMethod("onTouchUp"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onTouchUp", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onRightMouseDown(const GuiEvent &e)
- {
- if (mUseRightMouseDown && isMethod("onRightMouseDown"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onRightMouseDown", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onRightMouseDragged(const GuiEvent &e)
- {
- if (isMethod("onRightMouseDragged"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onRightMouseDragged", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onRightMouseUp(const GuiEvent &e)
- {
- if (mUseRightMouseDown && isMethod("onRightMouseUp"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onRightMouseUp", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onMiddleMouseDown(const GuiEvent &e)
- {
- if (mUseMiddleMouseDown && isMethod("onMiddleMouseDown"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onMiddleMouseDown", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onMiddleMouseDragged(const GuiEvent &e)
- {
- if (isMethod("onMiddleMouseDragged"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onMiddleMouseDragged", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onMiddleMouseUp(const GuiEvent &e)
- {
- if (mUseMiddleMouseDown && isMethod("onMiddleMouseUp"))
- {
- char* point = Con::getArgBuffer(32);
- dSprintf(point, 32, "%d %d", e.mousePoint.x, e.mousePoint.y);
- Con::executef(this, 2, "onMiddleMouseUp", point);
- return true;
- }
- return false;
- }
- bool EditorToyTool::onInputEvent(const GuiEvent &e)
- {
- if (!mUseKeyInput)
- return false;
- Con::executef(this,3, "onKeyPress", e.ascii, e.modifier);
- return true;
- }
|