editor_plugin_list.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**************************************************************************/
  2. /* editor_plugin_list.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "editor_plugin_list.h"
  31. bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) const {
  32. bool discard = false;
  33. for (EditorPlugin *plugin : plugins_list) {
  34. if (plugin->forward_canvas_gui_input(p_event)) {
  35. discard = true;
  36. }
  37. }
  38. return discard;
  39. }
  40. EditorPlugin::AfterGUIInput EditorPluginList::forward_3d_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool p_serve_when_force_input_enabled) const {
  41. EditorPlugin::AfterGUIInput after = EditorPlugin::AFTER_GUI_INPUT_PASS;
  42. for (EditorPlugin *plugin : plugins_list) {
  43. if (!p_serve_when_force_input_enabled && plugin->is_input_event_forwarding_always_enabled()) {
  44. continue;
  45. }
  46. EditorPlugin::AfterGUIInput current_after = plugin->forward_3d_gui_input(p_camera, p_event);
  47. if (current_after == EditorPlugin::AFTER_GUI_INPUT_STOP) {
  48. after = EditorPlugin::AFTER_GUI_INPUT_STOP;
  49. }
  50. if (after != EditorPlugin::AFTER_GUI_INPUT_STOP && current_after == EditorPlugin::AFTER_GUI_INPUT_CUSTOM) {
  51. after = EditorPlugin::AFTER_GUI_INPUT_CUSTOM;
  52. }
  53. }
  54. return after;
  55. }
  56. void EditorPluginList::forward_canvas_draw_over_viewport(Control *p_overlay) const {
  57. for (EditorPlugin *plugin : plugins_list) {
  58. plugin->forward_canvas_draw_over_viewport(p_overlay);
  59. }
  60. }
  61. void EditorPluginList::forward_canvas_force_draw_over_viewport(Control *p_overlay) const {
  62. for (EditorPlugin *plugin : plugins_list) {
  63. plugin->forward_canvas_force_draw_over_viewport(p_overlay);
  64. }
  65. }
  66. void EditorPluginList::forward_3d_draw_over_viewport(Control *p_overlay) const {
  67. for (EditorPlugin *plugin : plugins_list) {
  68. plugin->forward_3d_draw_over_viewport(p_overlay);
  69. }
  70. }
  71. void EditorPluginList::forward_3d_force_draw_over_viewport(Control *p_overlay) const {
  72. for (EditorPlugin *plugin : plugins_list) {
  73. plugin->forward_3d_force_draw_over_viewport(p_overlay);
  74. }
  75. }
  76. void EditorPluginList::add_plugin(EditorPlugin *p_plugin) {
  77. ERR_FAIL_COND(plugins_list.has(p_plugin));
  78. plugins_list.push_back(p_plugin);
  79. }
  80. void EditorPluginList::remove_plugin(EditorPlugin *p_plugin) {
  81. plugins_list.erase(p_plugin);
  82. }