MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / edit_item

Method edit_item

editor/editor_node.cpp:2551–2647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2549}
2550
2551void EditorNode::edit_item(Object *p_object, Object *p_editing_owner) {
2552 ERR_FAIL_NULL(p_editing_owner);
2553
2554 // Editing for this type of object may be disabled by user's feature profile.
2555 if (!p_object || _is_class_editor_disabled_by_feature_profile(p_object->get_class())) {
2556 // Nothing to edit, clean up the owner context and return.
2557 hide_unused_editors(p_editing_owner);
2558 return;
2559 }
2560
2561 // Get a list of editor plugins that can handle this type of object.
2562 Vector<EditorPlugin *> available_plugins = editor_data.get_handling_sub_editors(p_object);
2563 if (available_plugins.is_empty()) {
2564 // None, clean up the owner context and return.
2565 hide_unused_editors(p_editing_owner);
2566 return;
2567 }
2568
2569 ObjectID owner_id = p_editing_owner->get_instance_id();
2570
2571 // Remove editor plugins no longer used by this editing owner. Keep the ones that can
2572 // still be reused by the new edited object.
2573
2574 List<EditorPlugin *> to_remove;
2575 for (EditorPlugin *plugin : active_plugins[owner_id]) {
2576 if (!available_plugins.has(plugin)) {
2577 to_remove.push_back(plugin);
2578 if (plugin->can_auto_hide()) {
2579 _plugin_over_edit(plugin, nullptr);
2580 } else {
2581 // If plugin can't be hidden, make it own itself and become responsible for closing.
2582 _plugin_over_self_own(plugin);
2583 }
2584 }
2585 }
2586
2587 for (EditorPlugin *plugin : to_remove) {
2588 active_plugins[owner_id].erase(plugin);
2589 }
2590
2591 LocalVector<EditorPlugin *> to_over_edit;
2592
2593 // Send the edited object to the plugins.
2594 for (EditorPlugin *plugin : available_plugins) {
2595 if (active_plugins[owner_id].has(plugin)) {
2596 // Plugin was already active, just change the object and ensure it's visible.
2597 plugin->make_visible(true);
2598 plugin->edit(p_object);
2599 continue;
2600 }
2601
2602 if (active_plugins.has(plugin->get_instance_id())) {
2603 // Plugin is already active, but as self-owning, so it needs a separate check.
2604 plugin->make_visible(true);
2605 plugin->edit(p_object);
2606 continue;
2607 }
2608

Callers 2

_open_editor_pressedMethod · 0.80
_menu_option_confirmMethod · 0.80

Calls 12

fold_resourceMethod · 0.80
get_classMethod · 0.45
is_emptyMethod · 0.45
get_instance_idMethod · 0.45
hasMethod · 0.45
push_backMethod · 0.45
can_auto_hideMethod · 0.45
eraseMethod · 0.45
make_visibleMethod · 0.45
editMethod · 0.45
insertMethod · 0.45

Tested by 1

_menu_option_confirmMethod · 0.64