editor_plugin.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. /*************************************************************************/
  2. /* editor_plugin.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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.h"
  31. #include "editor/editor_export.h"
  32. #include "editor/editor_node.h"
  33. #include "editor/editor_settings.h"
  34. #include "editor/filesystem_dock.h"
  35. #include "editor/project_settings_editor.h"
  36. #include "editor_resource_preview.h"
  37. #include "main/main.h"
  38. #include "plugins/canvas_item_editor_plugin.h"
  39. #include "plugins/spatial_editor_plugin.h"
  40. #include "scene/3d/camera.h"
  41. #include "scene/gui/popup_menu.h"
  42. #include "servers/visual_server.h"
  43. Array EditorInterface::_make_mesh_previews(const Array &p_meshes, int p_preview_size) {
  44. Vector<Ref<Mesh> > meshes;
  45. for (int i = 0; i < p_meshes.size(); i++) {
  46. meshes.push_back(p_meshes[i]);
  47. }
  48. Vector<Ref<Texture> > textures = make_mesh_previews(meshes, NULL, p_preview_size);
  49. Array ret;
  50. for (int i = 0; i < textures.size(); i++) {
  51. ret.push_back(textures[i]);
  52. }
  53. return ret;
  54. }
  55. Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> > &p_meshes, Vector<Transform> *p_transforms, int p_preview_size) {
  56. int size = p_preview_size;
  57. RID scenario = VS::get_singleton()->scenario_create();
  58. RID viewport = VS::get_singleton()->viewport_create();
  59. VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ALWAYS);
  60. VS::get_singleton()->viewport_set_vflip(viewport, true);
  61. VS::get_singleton()->viewport_set_scenario(viewport, scenario);
  62. VS::get_singleton()->viewport_set_size(viewport, size, size);
  63. VS::get_singleton()->viewport_set_transparent_background(viewport, true);
  64. VS::get_singleton()->viewport_set_active(viewport, true);
  65. RID viewport_texture = VS::get_singleton()->viewport_get_texture(viewport);
  66. RID camera = VS::get_singleton()->camera_create();
  67. VS::get_singleton()->viewport_attach_camera(viewport, camera);
  68. RID light = VS::get_singleton()->directional_light_create();
  69. RID light_instance = VS::get_singleton()->instance_create2(light, scenario);
  70. RID light2 = VS::get_singleton()->directional_light_create();
  71. VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7));
  72. RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario);
  73. EditorProgress ep("mlib", TTR("Creating Mesh Previews"), p_meshes.size());
  74. Vector<Ref<Texture> > textures;
  75. for (int i = 0; i < p_meshes.size(); i++) {
  76. Ref<Mesh> mesh = p_meshes[i];
  77. if (!mesh.is_valid()) {
  78. textures.push_back(Ref<Texture>());
  79. continue;
  80. }
  81. Transform mesh_xform;
  82. if (p_transforms != NULL) {
  83. mesh_xform = (*p_transforms)[i];
  84. }
  85. RID inst = VS::get_singleton()->instance_create2(mesh->get_rid(), scenario);
  86. VS::get_singleton()->instance_set_transform(inst, mesh_xform);
  87. AABB aabb = mesh->get_aabb();
  88. Vector3 ofs = aabb.position + aabb.size * 0.5;
  89. aabb.position -= ofs;
  90. Transform xform;
  91. xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI / 6);
  92. xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI / 6) * xform.basis;
  93. AABB rot_aabb = xform.xform(aabb);
  94. float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
  95. if (m == 0) {
  96. textures.push_back(Ref<Texture>());
  97. continue;
  98. }
  99. xform.origin = -xform.basis.xform(ofs); //-ofs*m;
  100. xform.origin.z -= rot_aabb.size.z * 2;
  101. xform.invert();
  102. xform = mesh_xform * xform;
  103. VS::get_singleton()->camera_set_transform(camera, xform * Transform(Basis(), Vector3(0, 0, 3)));
  104. VS::get_singleton()->camera_set_orthogonal(camera, m * 2, 0.01, 1000.0);
  105. VS::get_singleton()->instance_set_transform(light_instance, xform * Transform().looking_at(Vector3(-2, -1, -1), Vector3(0, 1, 0)));
  106. VS::get_singleton()->instance_set_transform(light_instance2, xform * Transform().looking_at(Vector3(+1, -1, -2), Vector3(0, 1, 0)));
  107. ep.step(TTR("Thumbnail..."), i);
  108. Main::iteration();
  109. Main::iteration();
  110. Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture);
  111. ERR_CONTINUE(!img.is_valid() || img->empty());
  112. Ref<ImageTexture> it(memnew(ImageTexture));
  113. it->create_from_image(img);
  114. VS::get_singleton()->free(inst);
  115. textures.push_back(it);
  116. }
  117. VS::get_singleton()->free(viewport);
  118. VS::get_singleton()->free(light);
  119. VS::get_singleton()->free(light_instance);
  120. VS::get_singleton()->free(light2);
  121. VS::get_singleton()->free(light_instance2);
  122. VS::get_singleton()->free(camera);
  123. VS::get_singleton()->free(scenario);
  124. return textures;
  125. }
  126. void EditorInterface::set_main_screen_editor(const String &p_name) {
  127. EditorNode::get_singleton()->select_editor_by_name(p_name);
  128. }
  129. Control *EditorInterface::get_editor_viewport() {
  130. return EditorNode::get_singleton()->get_viewport();
  131. }
  132. void EditorInterface::edit_resource(const Ref<Resource> &p_resource) {
  133. EditorNode::get_singleton()->edit_resource(p_resource);
  134. }
  135. void EditorInterface::edit_node(Node *p_node) {
  136. EditorNode::get_singleton()->edit_node(p_node);
  137. }
  138. void EditorInterface::open_scene_from_path(const String &scene_path) {
  139. if (EditorNode::get_singleton()->is_changing_scene()) {
  140. return;
  141. }
  142. EditorNode::get_singleton()->open_request(scene_path);
  143. }
  144. void EditorInterface::reload_scene_from_path(const String &scene_path) {
  145. if (EditorNode::get_singleton()->is_changing_scene()) {
  146. return;
  147. }
  148. EditorNode::get_singleton()->reload_scene(scene_path);
  149. }
  150. void EditorInterface::play_main_scene() {
  151. EditorNode::get_singleton()->run_play();
  152. }
  153. void EditorInterface::play_current_scene() {
  154. EditorNode::get_singleton()->run_play_current();
  155. }
  156. void EditorInterface::play_custom_scene(const String &scene_path) {
  157. EditorNode::get_singleton()->run_play_custom(scene_path);
  158. }
  159. void EditorInterface::stop_playing_scene() {
  160. EditorNode::get_singleton()->run_stop();
  161. }
  162. bool EditorInterface::is_playing_scene() const {
  163. return EditorNode::get_singleton()->is_run_playing();
  164. }
  165. String EditorInterface::get_playing_scene() const {
  166. return EditorNode::get_singleton()->get_run_playing_scene();
  167. }
  168. Node *EditorInterface::get_edited_scene_root() {
  169. return EditorNode::get_singleton()->get_edited_scene();
  170. }
  171. Array EditorInterface::get_open_scenes() const {
  172. Array ret;
  173. Vector<EditorData::EditedScene> scenes = EditorNode::get_editor_data().get_edited_scenes();
  174. int scns_amount = scenes.size();
  175. for (int idx_scn = 0; idx_scn < scns_amount; idx_scn++) {
  176. if (scenes[idx_scn].root == NULL)
  177. continue;
  178. ret.push_back(scenes[idx_scn].root->get_filename());
  179. }
  180. return ret;
  181. }
  182. ScriptEditor *EditorInterface::get_script_editor() {
  183. return ScriptEditor::get_singleton();
  184. }
  185. void EditorInterface::select_file(const String &p_file) {
  186. EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file);
  187. }
  188. String EditorInterface::get_selected_path() const {
  189. return EditorNode::get_singleton()->get_filesystem_dock()->get_selected_path();
  190. }
  191. String EditorInterface::get_current_path() const {
  192. return EditorNode::get_singleton()->get_filesystem_dock()->get_current_path();
  193. }
  194. void EditorInterface::inspect_object(Object *p_obj, const String &p_for_property, bool p_inspector_only) {
  195. EditorNode::get_singleton()->push_item(p_obj, p_for_property, p_inspector_only);
  196. }
  197. EditorFileSystem *EditorInterface::get_resource_file_system() {
  198. return EditorFileSystem::get_singleton();
  199. }
  200. FileSystemDock *EditorInterface::get_file_system_dock() {
  201. return EditorNode::get_singleton()->get_filesystem_dock();
  202. }
  203. EditorSelection *EditorInterface::get_selection() {
  204. return EditorNode::get_singleton()->get_editor_selection();
  205. }
  206. Ref<EditorSettings> EditorInterface::get_editor_settings() {
  207. return EditorSettings::get_singleton();
  208. }
  209. EditorResourcePreview *EditorInterface::get_resource_previewer() {
  210. return EditorResourcePreview::get_singleton();
  211. }
  212. Control *EditorInterface::get_base_control() {
  213. return EditorNode::get_singleton()->get_gui_base();
  214. }
  215. float EditorInterface::get_editor_scale() const {
  216. return EDSCALE;
  217. }
  218. void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
  219. EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled, true);
  220. }
  221. bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
  222. return EditorNode::get_singleton()->is_addon_plugin_enabled(p_plugin);
  223. }
  224. EditorInspector *EditorInterface::get_inspector() const {
  225. return EditorNode::get_singleton()->get_inspector();
  226. }
  227. Error EditorInterface::save_scene() {
  228. if (!get_edited_scene_root())
  229. return ERR_CANT_CREATE;
  230. if (get_edited_scene_root()->get_filename() == String())
  231. return ERR_CANT_CREATE;
  232. save_scene_as(get_edited_scene_root()->get_filename());
  233. return OK;
  234. }
  235. void EditorInterface::save_scene_as(const String &p_scene, bool p_with_preview) {
  236. EditorNode::get_singleton()->save_scene_to_path(p_scene, p_with_preview);
  237. }
  238. void EditorInterface::set_distraction_free_mode(bool p_enter) {
  239. EditorNode::get_singleton()->set_distraction_free_mode(p_enter);
  240. }
  241. EditorInterface *EditorInterface::singleton = NULL;
  242. bool EditorInterface::is_distraction_free_mode_enabled() const {
  243. return EditorNode::get_singleton()->is_distraction_free_mode_enabled();
  244. }
  245. void EditorInterface::_bind_methods() {
  246. ClassDB::bind_method(D_METHOD("inspect_object", "object", "for_property", "inspector_only"), &EditorInterface::inspect_object, DEFVAL(String()), DEFVAL(false));
  247. ClassDB::bind_method(D_METHOD("get_selection"), &EditorInterface::get_selection);
  248. ClassDB::bind_method(D_METHOD("get_editor_settings"), &EditorInterface::get_editor_settings);
  249. ClassDB::bind_method(D_METHOD("get_script_editor"), &EditorInterface::get_script_editor);
  250. ClassDB::bind_method(D_METHOD("get_base_control"), &EditorInterface::get_base_control);
  251. ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);
  252. ClassDB::bind_method(D_METHOD("edit_resource", "resource"), &EditorInterface::edit_resource);
  253. ClassDB::bind_method(D_METHOD("edit_node", "node"), &EditorInterface::edit_node);
  254. ClassDB::bind_method(D_METHOD("open_scene_from_path", "scene_filepath"), &EditorInterface::open_scene_from_path);
  255. ClassDB::bind_method(D_METHOD("reload_scene_from_path", "scene_filepath"), &EditorInterface::reload_scene_from_path);
  256. ClassDB::bind_method(D_METHOD("play_main_scene"), &EditorInterface::play_main_scene);
  257. ClassDB::bind_method(D_METHOD("play_current_scene"), &EditorInterface::play_current_scene);
  258. ClassDB::bind_method(D_METHOD("play_custom_scene", "scene_filepath"), &EditorInterface::play_custom_scene);
  259. ClassDB::bind_method(D_METHOD("stop_playing_scene"), &EditorInterface::stop_playing_scene);
  260. ClassDB::bind_method(D_METHOD("is_playing_scene"), &EditorInterface::is_playing_scene);
  261. ClassDB::bind_method(D_METHOD("get_playing_scene"), &EditorInterface::get_playing_scene);
  262. ClassDB::bind_method(D_METHOD("get_open_scenes"), &EditorInterface::get_open_scenes);
  263. ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &EditorInterface::get_edited_scene_root);
  264. ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer);
  265. ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system);
  266. ClassDB::bind_method(D_METHOD("get_editor_viewport"), &EditorInterface::get_editor_viewport);
  267. ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews);
  268. ClassDB::bind_method(D_METHOD("select_file", "file"), &EditorInterface::select_file);
  269. ClassDB::bind_method(D_METHOD("get_selected_path"), &EditorInterface::get_selected_path);
  270. ClassDB::bind_method(D_METHOD("get_current_path"), &EditorInterface::get_current_path);
  271. ClassDB::bind_method(D_METHOD("get_file_system_dock"), &EditorInterface::get_file_system_dock);
  272. ClassDB::bind_method(D_METHOD("set_plugin_enabled", "plugin", "enabled"), &EditorInterface::set_plugin_enabled);
  273. ClassDB::bind_method(D_METHOD("is_plugin_enabled", "plugin"), &EditorInterface::is_plugin_enabled);
  274. ClassDB::bind_method(D_METHOD("get_inspector"), &EditorInterface::get_inspector);
  275. ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene);
  276. ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true));
  277. ClassDB::bind_method(D_METHOD("set_main_screen_editor", "name"), &EditorInterface::set_main_screen_editor);
  278. ClassDB::bind_method(D_METHOD("set_distraction_free_mode", "enter"), &EditorInterface::set_distraction_free_mode);
  279. ClassDB::bind_method(D_METHOD("is_distraction_free_mode_enabled"), &EditorInterface::is_distraction_free_mode_enabled);
  280. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distraction_free_mode"), "set_distraction_free_mode", "is_distraction_free_mode_enabled");
  281. }
  282. EditorInterface::EditorInterface() {
  283. singleton = this;
  284. }
  285. ///////////////////////////////////////////
  286. void EditorPlugin::add_custom_type(const String &p_type, const String &p_base, const Ref<Script> &p_script, const Ref<Texture> &p_icon) {
  287. EditorNode::get_editor_data().add_custom_type(p_type, p_base, p_script, p_icon);
  288. }
  289. void EditorPlugin::remove_custom_type(const String &p_type) {
  290. EditorNode::get_editor_data().remove_custom_type(p_type);
  291. }
  292. void EditorPlugin::add_autoload_singleton(const String &p_name, const String &p_path) {
  293. EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path);
  294. }
  295. void EditorPlugin::remove_autoload_singleton(const String &p_name) {
  296. EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_remove(p_name);
  297. }
  298. ToolButton *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const String &p_title) {
  299. ERR_FAIL_NULL_V(p_control, NULL);
  300. return EditorNode::get_singleton()->add_bottom_panel_item(p_title, p_control);
  301. }
  302. void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control) {
  303. ERR_FAIL_NULL(p_control);
  304. EditorNode::get_singleton()->add_control_to_dock(EditorNode::DockSlot(p_slot), p_control);
  305. }
  306. void EditorPlugin::remove_control_from_docks(Control *p_control) {
  307. ERR_FAIL_NULL(p_control);
  308. EditorNode::get_singleton()->remove_control_from_dock(p_control);
  309. }
  310. void EditorPlugin::remove_control_from_bottom_panel(Control *p_control) {
  311. ERR_FAIL_NULL(p_control);
  312. EditorNode::get_singleton()->remove_bottom_panel_item(p_control);
  313. }
  314. void EditorPlugin::add_control_to_container(CustomControlContainer p_location, Control *p_control) {
  315. ERR_FAIL_NULL(p_control);
  316. switch (p_location) {
  317. case CONTAINER_TOOLBAR: {
  318. EditorNode::get_menu_hb()->add_child(p_control);
  319. } break;
  320. case CONTAINER_SPATIAL_EDITOR_MENU: {
  321. SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control);
  322. } break;
  323. case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
  324. SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
  325. SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
  326. } break;
  327. case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
  328. SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
  329. SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
  330. } break;
  331. case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
  332. SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control);
  333. } break;
  334. case CONTAINER_CANVAS_EDITOR_MENU: {
  335. CanvasItemEditor::get_singleton()->add_control_to_menu_panel(p_control);
  336. } break;
  337. case CONTAINER_CANVAS_EDITOR_SIDE_LEFT: {
  338. CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
  339. CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
  340. } break;
  341. case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
  342. CanvasItemEditor::get_singleton()->get_palette_split()->add_child(p_control);
  343. CanvasItemEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
  344. } break;
  345. case CONTAINER_CANVAS_EDITOR_BOTTOM: {
  346. CanvasItemEditor::get_singleton()->get_bottom_split()->add_child(p_control);
  347. } break;
  348. case CONTAINER_PROPERTY_EDITOR_BOTTOM: {
  349. EditorNode::get_singleton()->get_inspector_dock_addon_area()->add_child(p_control);
  350. } break;
  351. case CONTAINER_PROJECT_SETTING_TAB_LEFT: {
  352. ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
  353. ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 0);
  354. } break;
  355. case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
  356. ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(p_control);
  357. ProjectSettingsEditor::get_singleton()->get_tabs()->move_child(p_control, 1);
  358. } break;
  359. }
  360. }
  361. void EditorPlugin::remove_control_from_container(CustomControlContainer p_location, Control *p_control) {
  362. ERR_FAIL_NULL(p_control);
  363. switch (p_location) {
  364. case CONTAINER_TOOLBAR: {
  365. EditorNode::get_menu_hb()->remove_child(p_control);
  366. } break;
  367. case CONTAINER_SPATIAL_EDITOR_MENU: {
  368. SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control);
  369. } break;
  370. case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT:
  371. case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
  372. SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control);
  373. } break;
  374. case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
  375. SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control);
  376. } break;
  377. case CONTAINER_CANVAS_EDITOR_MENU: {
  378. CanvasItemEditor::get_singleton()->remove_control_from_menu_panel(p_control);
  379. } break;
  380. case CONTAINER_CANVAS_EDITOR_SIDE_LEFT:
  381. case CONTAINER_CANVAS_EDITOR_SIDE_RIGHT: {
  382. CanvasItemEditor::get_singleton()->get_palette_split()->remove_child(p_control);
  383. } break;
  384. case CONTAINER_CANVAS_EDITOR_BOTTOM: {
  385. CanvasItemEditor::get_singleton()->get_bottom_split()->remove_child(p_control);
  386. } break;
  387. case CONTAINER_PROPERTY_EDITOR_BOTTOM: {
  388. EditorNode::get_singleton()->get_inspector_dock_addon_area()->remove_child(p_control);
  389. } break;
  390. case CONTAINER_PROJECT_SETTING_TAB_LEFT:
  391. case CONTAINER_PROJECT_SETTING_TAB_RIGHT: {
  392. ProjectSettingsEditor::get_singleton()->get_tabs()->remove_child(p_control);
  393. } break;
  394. }
  395. }
  396. void EditorPlugin::add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud) {
  397. EditorNode::get_singleton()->add_tool_menu_item(p_name, p_handler, p_callback, p_ud);
  398. }
  399. void EditorPlugin::add_tool_submenu_item(const String &p_name, Object *p_submenu) {
  400. ERR_FAIL_NULL(p_submenu);
  401. PopupMenu *submenu = Object::cast_to<PopupMenu>(p_submenu);
  402. ERR_FAIL_NULL(submenu);
  403. EditorNode::get_singleton()->add_tool_submenu_item(p_name, submenu);
  404. }
  405. void EditorPlugin::remove_tool_menu_item(const String &p_name) {
  406. EditorNode::get_singleton()->remove_tool_menu_item(p_name);
  407. }
  408. void EditorPlugin::set_input_event_forwarding_always_enabled() {
  409. input_event_forwarding_always_enabled = true;
  410. EditorPluginList *always_input_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_input_forwarding();
  411. always_input_forwarding_list->add_plugin(this);
  412. }
  413. void EditorPlugin::set_force_draw_over_forwarding_enabled() {
  414. force_draw_over_forwarding_enabled = true;
  415. EditorPluginList *always_draw_over_forwarding_list = EditorNode::get_singleton()->get_editor_plugins_force_over();
  416. always_draw_over_forwarding_list->add_plugin(this);
  417. }
  418. void EditorPlugin::notify_scene_changed(const Node *scn_root) {
  419. emit_signal("scene_changed", scn_root);
  420. }
  421. void EditorPlugin::notify_main_screen_changed(const String &screen_name) {
  422. if (screen_name == last_main_screen_name)
  423. return;
  424. emit_signal("main_screen_changed", screen_name);
  425. last_main_screen_name = screen_name;
  426. }
  427. void EditorPlugin::notify_scene_closed(const String &scene_filepath) {
  428. emit_signal("scene_closed", scene_filepath);
  429. }
  430. void EditorPlugin::notify_resource_saved(const Ref<Resource> &p_resource) {
  431. emit_signal("resource_saved", p_resource);
  432. }
  433. bool EditorPlugin::forward_canvas_gui_input(const Ref<InputEvent> &p_event) {
  434. if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) {
  435. return get_script_instance()->call("forward_canvas_gui_input", p_event);
  436. }
  437. return false;
  438. }
  439. void EditorPlugin::forward_canvas_draw_over_viewport(Control *p_overlay) {
  440. if (get_script_instance() && get_script_instance()->has_method("forward_canvas_draw_over_viewport")) {
  441. get_script_instance()->call("forward_canvas_draw_over_viewport", p_overlay);
  442. }
  443. }
  444. void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
  445. if (get_script_instance() && get_script_instance()->has_method("forward_canvas_force_draw_over_viewport")) {
  446. get_script_instance()->call("forward_canvas_force_draw_over_viewport", p_overlay);
  447. }
  448. }
  449. // Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
  450. int EditorPlugin::update_overlays() const {
  451. if (SpatialEditor::get_singleton()->is_visible()) {
  452. int count = 0;
  453. for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
  454. SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i);
  455. if (vp->is_visible()) {
  456. vp->update_surface();
  457. count++;
  458. }
  459. }
  460. return count;
  461. } else {
  462. // This will update the normal viewport itself as well
  463. CanvasItemEditor::get_singleton()->get_viewport_control()->update();
  464. return 1;
  465. }
  466. }
  467. bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
  468. if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
  469. return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
  470. }
  471. return false;
  472. }
  473. void EditorPlugin::forward_spatial_draw_over_viewport(Control *p_overlay) {
  474. if (get_script_instance() && get_script_instance()->has_method("forward_spatial_draw_over_viewport")) {
  475. get_script_instance()->call("forward_spatial_draw_over_viewport", p_overlay);
  476. }
  477. }
  478. void EditorPlugin::forward_spatial_force_draw_over_viewport(Control *p_overlay) {
  479. if (get_script_instance() && get_script_instance()->has_method("forward_spatial_force_draw_over_viewport")) {
  480. get_script_instance()->call("forward_spatial_force_draw_over_viewport", p_overlay);
  481. }
  482. }
  483. String EditorPlugin::get_name() const {
  484. if (get_script_instance() && get_script_instance()->has_method("get_plugin_name")) {
  485. return get_script_instance()->call("get_plugin_name");
  486. }
  487. return String();
  488. }
  489. const Ref<Texture> EditorPlugin::get_icon() const {
  490. if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) {
  491. return get_script_instance()->call("get_plugin_icon");
  492. }
  493. return Ref<Texture>();
  494. }
  495. bool EditorPlugin::has_main_screen() const {
  496. if (get_script_instance() && get_script_instance()->has_method("has_main_screen")) {
  497. return get_script_instance()->call("has_main_screen");
  498. }
  499. return false;
  500. }
  501. void EditorPlugin::make_visible(bool p_visible) {
  502. if (get_script_instance() && get_script_instance()->has_method("make_visible")) {
  503. get_script_instance()->call("make_visible", p_visible);
  504. }
  505. }
  506. void EditorPlugin::edit(Object *p_object) {
  507. if (get_script_instance() && get_script_instance()->has_method("edit")) {
  508. if (p_object->is_class("Resource")) {
  509. get_script_instance()->call("edit", Ref<Resource>(Object::cast_to<Resource>(p_object)));
  510. } else {
  511. get_script_instance()->call("edit", p_object);
  512. }
  513. }
  514. }
  515. bool EditorPlugin::handles(Object *p_object) const {
  516. if (get_script_instance() && get_script_instance()->has_method("handles")) {
  517. return get_script_instance()->call("handles", p_object);
  518. }
  519. return false;
  520. }
  521. Dictionary EditorPlugin::get_state() const {
  522. if (get_script_instance() && get_script_instance()->has_method("get_state")) {
  523. return get_script_instance()->call("get_state");
  524. }
  525. return Dictionary();
  526. }
  527. void EditorPlugin::set_state(const Dictionary &p_state) {
  528. if (get_script_instance() && get_script_instance()->has_method("set_state")) {
  529. get_script_instance()->call("set_state", p_state);
  530. }
  531. }
  532. void EditorPlugin::clear() {
  533. if (get_script_instance() && get_script_instance()->has_method("clear")) {
  534. get_script_instance()->call("clear");
  535. }
  536. }
  537. // if editor references external resources/scenes, save them
  538. void EditorPlugin::save_external_data() {
  539. if (get_script_instance() && get_script_instance()->has_method("save_external_data")) {
  540. get_script_instance()->call("save_external_data");
  541. }
  542. }
  543. // if changes are pending in editor, apply them
  544. void EditorPlugin::apply_changes() {
  545. if (get_script_instance() && get_script_instance()->has_method("apply_changes")) {
  546. get_script_instance()->call("apply_changes");
  547. }
  548. }
  549. void EditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
  550. if (get_script_instance() && get_script_instance()->has_method("get_breakpoints")) {
  551. PoolStringArray arr = get_script_instance()->call("get_breakpoints");
  552. for (int i = 0; i < arr.size(); i++)
  553. p_breakpoints->push_back(arr[i]);
  554. }
  555. }
  556. bool EditorPlugin::get_remove_list(List<Node *> *p_list) {
  557. return false;
  558. }
  559. void EditorPlugin::restore_global_state() {}
  560. void EditorPlugin::save_global_state() {}
  561. void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
  562. ERR_FAIL_COND(!p_importer.is_valid());
  563. ResourceFormatImporter::get_singleton()->add_importer(p_importer);
  564. EditorFileSystem::get_singleton()->call_deferred("scan");
  565. }
  566. void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) {
  567. ERR_FAIL_COND(!p_importer.is_valid());
  568. ResourceFormatImporter::get_singleton()->remove_importer(p_importer);
  569. EditorFileSystem::get_singleton()->call_deferred("scan");
  570. }
  571. void EditorPlugin::add_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
  572. ERR_FAIL_COND(!p_exporter.is_valid());
  573. EditorExport::get_singleton()->add_export_plugin(p_exporter);
  574. }
  575. void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter) {
  576. ERR_FAIL_COND(!p_exporter.is_valid());
  577. EditorExport::get_singleton()->remove_export_plugin(p_exporter);
  578. }
  579. void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) {
  580. ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
  581. SpatialEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
  582. }
  583. void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) {
  584. ERR_FAIL_COND(!p_gizmo_plugin.is_valid());
  585. SpatialEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
  586. }
  587. void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
  588. ERR_FAIL_COND(!p_plugin.is_valid());
  589. EditorInspector::add_inspector_plugin(p_plugin);
  590. }
  591. void EditorPlugin::remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
  592. ERR_FAIL_COND(!p_plugin.is_valid());
  593. EditorInspector::remove_inspector_plugin(p_plugin);
  594. }
  595. void EditorPlugin::add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
  596. ERR_FAIL_COND(!p_importer.is_valid());
  597. ResourceImporterScene::get_singleton()->add_importer(p_importer);
  598. }
  599. void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) {
  600. ERR_FAIL_COND(!p_importer.is_valid());
  601. ResourceImporterScene::get_singleton()->remove_importer(p_importer);
  602. }
  603. int find(const PoolStringArray &a, const String &v) {
  604. PoolStringArray::Read r = a.read();
  605. for (int j = 0; j < a.size(); ++j) {
  606. if (r[j] == v) {
  607. return j;
  608. }
  609. }
  610. return -1;
  611. }
  612. void EditorPlugin::enable_plugin() {
  613. // Called when the plugin gets enabled in project settings, after it's added to the tree.
  614. // You can implement it to register autoloads.
  615. if (get_script_instance() && get_script_instance()->has_method("enable_plugin")) {
  616. get_script_instance()->call("enable_plugin");
  617. }
  618. }
  619. void EditorPlugin::disable_plugin() {
  620. // Last function called when the plugin gets disabled in project settings.
  621. // Implement it to cleanup things from the project, such as unregister autoloads.
  622. if (get_script_instance() && get_script_instance()->has_method("disable_plugin")) {
  623. get_script_instance()->call("disable_plugin");
  624. }
  625. }
  626. void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) {
  627. if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) {
  628. get_script_instance()->call("set_window_layout", p_layout);
  629. }
  630. }
  631. void EditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
  632. if (get_script_instance() && get_script_instance()->has_method("get_window_layout")) {
  633. get_script_instance()->call("get_window_layout", p_layout);
  634. }
  635. }
  636. bool EditorPlugin::build() {
  637. if (get_script_instance() && get_script_instance()->has_method("build")) {
  638. return get_script_instance()->call("build");
  639. }
  640. return true;
  641. }
  642. void EditorPlugin::queue_save_layout() const {
  643. EditorNode::get_singleton()->save_layout();
  644. }
  645. void EditorPlugin::make_bottom_panel_item_visible(Control *p_item) {
  646. EditorNode::get_singleton()->make_bottom_panel_item_visible(p_item);
  647. }
  648. void EditorPlugin::hide_bottom_panel() {
  649. EditorNode::get_singleton()->hide_bottom_panel();
  650. }
  651. EditorInterface *EditorPlugin::get_editor_interface() {
  652. return EditorInterface::get_singleton();
  653. }
  654. ScriptCreateDialog *EditorPlugin::get_script_create_dialog() {
  655. return EditorNode::get_singleton()->get_script_create_dialog();
  656. }
  657. void EditorPlugin::_bind_methods() {
  658. ClassDB::bind_method(D_METHOD("add_control_to_container", "container", "control"), &EditorPlugin::add_control_to_container);
  659. ClassDB::bind_method(D_METHOD("add_control_to_bottom_panel", "control", "title"), &EditorPlugin::add_control_to_bottom_panel);
  660. ClassDB::bind_method(D_METHOD("add_control_to_dock", "slot", "control"), &EditorPlugin::add_control_to_dock);
  661. ClassDB::bind_method(D_METHOD("remove_control_from_docks", "control"), &EditorPlugin::remove_control_from_docks);
  662. ClassDB::bind_method(D_METHOD("remove_control_from_bottom_panel", "control"), &EditorPlugin::remove_control_from_bottom_panel);
  663. ClassDB::bind_method(D_METHOD("remove_control_from_container", "container", "control"), &EditorPlugin::remove_control_from_container);
  664. ClassDB::bind_method(D_METHOD("add_tool_menu_item", "name", "handler", "callback", "ud"), &EditorPlugin::add_tool_menu_item, DEFVAL(Variant()));
  665. ClassDB::bind_method(D_METHOD("add_tool_submenu_item", "name", "submenu"), &EditorPlugin::add_tool_submenu_item);
  666. ClassDB::bind_method(D_METHOD("remove_tool_menu_item", "name"), &EditorPlugin::remove_tool_menu_item);
  667. ClassDB::bind_method(D_METHOD("add_custom_type", "type", "base", "script", "icon"), &EditorPlugin::add_custom_type);
  668. ClassDB::bind_method(D_METHOD("remove_custom_type", "type"), &EditorPlugin::remove_custom_type);
  669. ClassDB::bind_method(D_METHOD("add_autoload_singleton", "name", "path"), &EditorPlugin::add_autoload_singleton);
  670. ClassDB::bind_method(D_METHOD("remove_autoload_singleton", "name"), &EditorPlugin::remove_autoload_singleton);
  671. ClassDB::bind_method(D_METHOD("update_overlays"), &EditorPlugin::update_overlays);
  672. ClassDB::bind_method(D_METHOD("make_bottom_panel_item_visible", "item"), &EditorPlugin::make_bottom_panel_item_visible);
  673. ClassDB::bind_method(D_METHOD("hide_bottom_panel"), &EditorPlugin::hide_bottom_panel);
  674. ClassDB::bind_method(D_METHOD("get_undo_redo"), &EditorPlugin::_get_undo_redo);
  675. ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout);
  676. ClassDB::bind_method(D_METHOD("add_import_plugin", "importer"), &EditorPlugin::add_import_plugin);
  677. ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin);
  678. ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin);
  679. ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin);
  680. ClassDB::bind_method(D_METHOD("add_export_plugin", "plugin"), &EditorPlugin::add_export_plugin);
  681. ClassDB::bind_method(D_METHOD("remove_export_plugin", "plugin"), &EditorPlugin::remove_export_plugin);
  682. ClassDB::bind_method(D_METHOD("add_spatial_gizmo_plugin", "plugin"), &EditorPlugin::add_spatial_gizmo_plugin);
  683. ClassDB::bind_method(D_METHOD("remove_spatial_gizmo_plugin", "plugin"), &EditorPlugin::remove_spatial_gizmo_plugin);
  684. ClassDB::bind_method(D_METHOD("add_inspector_plugin", "plugin"), &EditorPlugin::add_inspector_plugin);
  685. ClassDB::bind_method(D_METHOD("remove_inspector_plugin", "plugin"), &EditorPlugin::remove_inspector_plugin);
  686. ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled);
  687. ClassDB::bind_method(D_METHOD("set_force_draw_over_forwarding_enabled"), &EditorPlugin::set_force_draw_over_forwarding_enabled);
  688. ClassDB::bind_method(D_METHOD("get_editor_interface"), &EditorPlugin::get_editor_interface);
  689. ClassDB::bind_method(D_METHOD("get_script_create_dialog"), &EditorPlugin::get_script_create_dialog);
  690. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
  691. ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
  692. ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
  693. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
  694. ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
  695. ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_spatial_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
  696. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
  697. ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "get_plugin_icon"));
  698. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen"));
  699. ClassDB::add_virtual_method(get_class_static(), MethodInfo("make_visible", PropertyInfo(Variant::BOOL, "visible")));
  700. ClassDB::add_virtual_method(get_class_static(), MethodInfo("edit", PropertyInfo(Variant::OBJECT, "object")));
  701. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "handles", PropertyInfo(Variant::OBJECT, "object")));
  702. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::DICTIONARY, "get_state"));
  703. ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_state", PropertyInfo(Variant::DICTIONARY, "state")));
  704. ClassDB::add_virtual_method(get_class_static(), MethodInfo("clear"));
  705. ClassDB::add_virtual_method(get_class_static(), MethodInfo("save_external_data"));
  706. ClassDB::add_virtual_method(get_class_static(), MethodInfo("apply_changes"));
  707. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::POOL_STRING_ARRAY, "get_breakpoints"));
  708. ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
  709. ClassDB::add_virtual_method(get_class_static(), MethodInfo("get_window_layout", PropertyInfo(Variant::OBJECT, "layout", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile")));
  710. ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "build"));
  711. ClassDB::add_virtual_method(get_class_static(), MethodInfo("enable_plugin"));
  712. ClassDB::add_virtual_method(get_class_static(), MethodInfo("disable_plugin"));
  713. ADD_SIGNAL(MethodInfo("scene_changed", PropertyInfo(Variant::OBJECT, "scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node")));
  714. ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath")));
  715. ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name")));
  716. ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource")));
  717. BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR);
  718. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU);
  719. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT);
  720. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT);
  721. BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_BOTTOM);
  722. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_MENU);
  723. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_LEFT);
  724. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_SIDE_RIGHT);
  725. BIND_ENUM_CONSTANT(CONTAINER_CANVAS_EDITOR_BOTTOM);
  726. BIND_ENUM_CONSTANT(CONTAINER_PROPERTY_EDITOR_BOTTOM);
  727. BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_LEFT);
  728. BIND_ENUM_CONSTANT(CONTAINER_PROJECT_SETTING_TAB_RIGHT);
  729. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UL);
  730. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BL);
  731. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_UR);
  732. BIND_ENUM_CONSTANT(DOCK_SLOT_LEFT_BR);
  733. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UL);
  734. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BL);
  735. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_UR);
  736. BIND_ENUM_CONSTANT(DOCK_SLOT_RIGHT_BR);
  737. BIND_ENUM_CONSTANT(DOCK_SLOT_MAX);
  738. }
  739. EditorPlugin::EditorPlugin() :
  740. undo_redo(NULL),
  741. input_event_forwarding_always_enabled(false),
  742. force_draw_over_forwarding_enabled(false),
  743. last_main_screen_name("") {
  744. }
  745. EditorPlugin::~EditorPlugin() {
  746. }
  747. EditorPluginCreateFunc EditorPlugins::creation_funcs[MAX_CREATE_FUNCS];
  748. int EditorPlugins::creation_func_count = 0;