guiShaderEditor.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _GUISHADEREDITOR_H_
  23. #define _GUISHADEREDITOR_H_
  24. #ifndef _GUICONTROL_H_
  25. #include "gui/core/guiControl.h"
  26. #endif
  27. #ifndef _UNDO_H_
  28. #include "util/undo.h"
  29. #endif
  30. #ifndef _GFX_GFXDRAWER_H_
  31. #include "gfx/gfxDrawUtil.h"
  32. #endif
  33. #ifndef _SHADERNODE_H_
  34. #include "gui/shaderEditor/nodes/shaderNode.h"
  35. #endif // !_SHADERNODE_H_
  36. class GuiShaderEditor : public GuiControl
  37. {
  38. public:
  39. typedef GuiControl Parent;
  40. enum mouseModes { Selecting, MovingSelection, DragConnection, DragSelecting, DragClone };
  41. protected:
  42. // list
  43. typedef Vector<ShaderNode*> ShaderNodeVector;
  44. // all nodes in this graph.
  45. ShaderNodeVector mCurrNodes;
  46. // Undo
  47. SimGroup* mTrash;
  48. SimSet* mSelectedSet;
  49. // mouse interaction
  50. mouseModes mMouseDownMode;
  51. Point2I mLastMousePos;
  52. Point2I mLastDragPos;
  53. Point2I mSelectionAnchor;
  54. Point2I mDragBeginPoint;
  55. Vector<Point2I> mDragBeginPoints;
  56. bool mDragAddSelection;
  57. bool mDragMoveUndo;
  58. ShaderNodeVector mSelectedNodes;
  59. public:
  60. GuiShaderEditor();
  61. DECLARE_CONOBJECT(GuiShaderEditor);
  62. DECLARE_CATEGORY("Shader Editor");
  63. DECLARE_DESCRIPTION("Implements a shader node based editor.");
  64. bool onWake();
  65. void onSleep();
  66. static void initPersistFields();
  67. virtual bool onAdd() override;
  68. virtual void onRemove() override;
  69. virtual void onPreRender() override;
  70. virtual void onRender(Point2I offset, const RectI& updateRect) override;
  71. // interaction
  72. virtual bool onKeyDown(const GuiEvent& event) override;
  73. virtual void onMouseDown(const GuiEvent& event) override;
  74. virtual void onMouseUp(const GuiEvent& event) override;
  75. virtual void onMouseMove(const GuiEvent& event) override;
  76. virtual void onMiddleMouseDown(const GuiEvent& event) override;
  77. virtual bool onMouseWheelUp(const GuiEvent& event) override;
  78. virtual bool onMouseWheelDown(const GuiEvent& event) override;
  79. };
  80. #endif _GUISHADEREDITOR_H_