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

Method _go_to_tab

editor/script/script_editor_plugin.cpp:709–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709void ScriptEditor::_go_to_tab(int p_idx) {
710 ScriptEditorBase *current = _get_current_editor();
711 if (current) {
712 if (current->is_unsaved()) {
713 current->apply_code();
714 }
715 }
716
717 Control *c = tab_container->get_tab_control(p_idx);
718 if (!c) {
719 return;
720 }
721
722 if (history_pos >= 0 && history_pos < history.size() && history[history_pos].control == tab_container->get_current_tab_control()) {
723 Node *n = tab_container->get_current_tab_control();
724
725 if (Object::cast_to<ScriptEditorBase>(n)) {
726 history.write[history_pos].state = Object::cast_to<ScriptEditorBase>(n)->get_navigation_state();
727 }
728 if (Object::cast_to<EditorHelp>(n)) {
729 history.write[history_pos].state = Object::cast_to<EditorHelp>(n)->get_scroll();
730 }
731 }
732
733 history.resize(history_pos + 1);
734 ScriptHistory sh;
735 sh.control = c;
736 sh.state = Variant();
737
738 if (!lock_history && (history.is_empty() || history[history.size() - 1].control != sh.control)) {
739 history.push_back(sh);
740 history_pos++;
741 }
742
743 tab_container->set_current_tab(p_idx);
744
745 c = tab_container->get_current_tab_control();
746
747 if (Object::cast_to<ScriptEditorBase>(c)) {
748 script_name_label->set_text(Object::cast_to<ScriptEditorBase>(c)->get_name());
749 script_icon->set_texture(Object::cast_to<ScriptEditorBase>(c)->get_theme_icon());
750 if (is_visible_in_tree()) {
751 Object::cast_to<ScriptEditorBase>(c)->ensure_focus();
752 }
753
754 Ref<Script> scr = Object::cast_to<ScriptEditorBase>(c)->get_edited_resource();
755 if (scr.is_valid()) {
756 notify_script_changed(scr);
757 }
758
759 Object::cast_to<ScriptEditorBase>(c)->validate();
760 }
761 if (Object::cast_to<EditorHelp>(c)) {
762 script_name_label->set_text(Object::cast_to<EditorHelp>(c)->get_class());
763 script_icon->set_texture(get_editor_theme_icon(SNAME("Help")));
764 if (is_visible_in_tree()) {
765 Object::cast_to<EditorHelp>(c)->set_focused();
766 }

Callers

nothing calls this directly

Calls 15

get_tab_controlMethod · 0.80
set_focusedMethod · 0.80
sizeMethod · 0.65
VariantClass · 0.50
is_unsavedMethod · 0.45
apply_codeMethod · 0.45
get_navigation_stateMethod · 0.45
get_scrollMethod · 0.45
resizeMethod · 0.45
is_emptyMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected