editorTool.cpp

Engine/source/gui/worldEditor/tools/editorTool.cpp

More...

Detailed Description

Public Functions

IMPLEMENT_CONOBJECT(EditorTool )

render(SceneRenderState * )

  1
  2#include "editorTool.h"
  3
  4IMPLEMENT_CONOBJECT(EditorTool);
  5
  6EditorTool::EditorTool()
  7{
  8   mWorldEditor = NULL;
  9
 10   mUseMouseDown = true;
 11   mUseMouseUp = true;
 12   mUseMouseMove = true;
 13
 14   mUseRightMouseDown = false;
 15   mUseRightMouseUp = false;
 16   mUseRightMouseMove = false;
 17
 18   mUseMiddleMouseDown = true;
 19   mUseMiddleMouseUp = true;
 20   mUseMiddleMouseMove = true;
 21
 22   mUseKeyInput = true;
 23}
 24
 25bool EditorTool::onAdd()
 26{
 27   return Parent::onAdd();
 28}
 29
 30void EditorTool::onRemove()
 31{
 32   Parent::onRemove();
 33}
 34
 35//Called when the tool is activated on the World Editor
 36void EditorTool::onActivated(WorldEditor* editor)
 37{
 38   mWorldEditor = editor;
 39   Con::executef(this, "onActivated");
 40}
 41
 42//Called when the tool is deactivated on the World Editor
 43void EditorTool::onDeactivated()
 44{
 45   mWorldEditor = NULL;
 46   Con::executef(this, "onDeactivated");
 47}
 48
 49//
 50bool EditorTool::onMouseMove(const Gui3DMouseEvent &e)
 51{
 52   if (!mUseMouseDown)
 53      return false;
 54
 55   Con::executef(this, "onMouseMove", e.mousePoint);
 56   return true;
 57}
 58bool EditorTool::onMouseDown(const Gui3DMouseEvent &e)
 59{
 60   if (!mUseMouseDown)
 61      return false;
 62
 63   Con::executef(this, "onMouseDown", e.mousePoint);
 64   return true;
 65}
 66bool EditorTool::onMouseDragged(const Gui3DMouseEvent &e)
 67{
 68   Con::executef(this, "onMouseDragged", e.mousePoint);
 69   return true;
 70}
 71bool EditorTool::onMouseUp(const Gui3DMouseEvent &e)
 72{
 73   if (!mUseMouseDown)
 74      return false;
 75
 76   Con::executef(this, "onMouseUp", e.mousePoint);
 77   return true;
 78}
 79
 80//
 81bool EditorTool::onRightMouseDown(const Gui3DMouseEvent &e)
 82{
 83   if (!mUseRightMouseDown)
 84      return false;
 85
 86   Con::executef(this, "onRightMouseDown", e.mousePoint);
 87   return true;
 88}
 89bool EditorTool::onRightMouseDragged(const Gui3DMouseEvent &e)
 90{
 91   Con::executef(this, "onRightMouseDragged", e.mousePoint);
 92   return true;
 93}
 94bool EditorTool::onRightMouseUp(const Gui3DMouseEvent &e)
 95{
 96   if (!mUseRightMouseDown)
 97      return false;
 98
 99   Con::executef(this, "onRightMouseUp", e.mousePoint);
100   return true;
101}
102
103//
104bool EditorTool::onMiddleMouseDown(const Gui3DMouseEvent &e)
105{
106   if (!mUseMiddleMouseDown)
107      return false;
108
109   Con::executef(this, "onMiddleMouseDown", e.mousePoint);
110   return true;
111}
112bool EditorTool::onMiddleMouseDragged(const Gui3DMouseEvent &e)
113{
114   Con::executef(this, "onMiddleMouseDragged", e.mousePoint);
115   return true;
116}
117bool EditorTool::onMiddleMouseUp(const Gui3DMouseEvent &e)
118{
119   if (!mUseMiddleMouseDown)
120      return false;
121
122   Con::executef(this, "onMiddleMouseUp", e.mousePoint);
123   return true;
124}
125
126//
127bool EditorTool::onInputEvent(const InputEventInfo &e)
128{
129   if (!mUseKeyInput)
130      return false;
131
132   Con::executef(this, "onKeyPress", e.ascii, e.modifier);
133   return true;
134}
135
136//
137void render(SceneRenderState *);
138