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