Skip to content

Commit

Permalink
Port remaining connections to callable_mp
Browse files Browse the repository at this point in the history
  • Loading branch information
KoBeWi committed Sep 18, 2022
1 parent 4ab3fdc commit 882a4f8
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 101 deletions.
4 changes: 2 additions & 2 deletions editor/animation_bezier_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ void AnimationBezierTrackEdit::set_timeline(AnimationTimelineEdit *p_timeline) {

void AnimationBezierTrackEdit::set_editor(AnimationTrackEditor *p_editor) {
editor = p_editor;
connect("clear_selection", Callable(editor, "_clear_selection").bind(false));
connect("select_key", Callable(editor, "_key_selected"), CONNECT_DEFERRED);
connect("clear_selection", callable_mp(editor, &AnimationTrackEditor::_clear_selection).bind(false));
connect("select_key", callable_mp(editor, &AnimationTrackEditor::_key_selected), CONNECT_DEFERRED);
}

void AnimationBezierTrackEdit::_play_position_draw() {
Expand Down
18 changes: 5 additions & 13 deletions editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3420,9 +3420,6 @@ void AnimationTrackEditGroup::_zoom_changed() {
queue_redraw();
}

void AnimationTrackEditGroup::_bind_methods() {
}

AnimationTrackEditGroup::AnimationTrackEditGroup() {
set_mouse_filter(MOUSE_FILTER_PASS);
}
Expand Down Expand Up @@ -6457,16 +6454,11 @@ void AnimationTrackEditor::_select_all_tracks_for_copy() {
}

void AnimationTrackEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_animation_update"), &AnimationTrackEditor::_animation_update);
ClassDB::bind_method(D_METHOD("_track_grab_focus"), &AnimationTrackEditor::_track_grab_focus);
ClassDB::bind_method(D_METHOD("_update_tracks"), &AnimationTrackEditor::_update_tracks);
ClassDB::bind_method(D_METHOD("_redraw_tracks"), &AnimationTrackEditor::_redraw_tracks);
ClassDB::bind_method(D_METHOD("_clear_selection_for_anim"), &AnimationTrackEditor::_clear_selection_for_anim);
ClassDB::bind_method(D_METHOD("_select_at_anim"), &AnimationTrackEditor::_select_at_anim);

ClassDB::bind_method(D_METHOD("_key_selected"), &AnimationTrackEditor::_key_selected); // Still used by some connect_compat.
ClassDB::bind_method(D_METHOD("_key_deselected"), &AnimationTrackEditor::_key_deselected); // Still used by some connect_compat.
ClassDB::bind_method(D_METHOD("_clear_selection"), &AnimationTrackEditor::_clear_selection); // Still used by some connect_compat.
ClassDB::bind_method("_animation_update", &AnimationTrackEditor::_animation_update);
ClassDB::bind_method("_track_grab_focus", &AnimationTrackEditor::_track_grab_focus);
ClassDB::bind_method("_clear_selection_for_anim", &AnimationTrackEditor::_clear_selection_for_anim);
ClassDB::bind_method("_select_at_anim", &AnimationTrackEditor::_select_at_anim);
ClassDB::bind_method("_clear_selection", &AnimationTrackEditor::_clear_selection);

ClassDB::bind_method(D_METHOD("_bezier_track_set_key_handle_mode", "animation", "track_idx", "key_idx", "key_handle_mode", "key_handle_set_mode"), &AnimationTrackEditor::_bezier_track_set_key_handle_mode, DEFVAL(Animation::HANDLE_SET_MODE_NONE));

Expand Down
10 changes: 5 additions & 5 deletions editor/animation_track_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ class AnimationTrackEditGroup : public Control {
void _zoom_changed();

protected:
static void _bind_methods();
void _notification(int p_what);

public:
Expand Down Expand Up @@ -407,7 +406,6 @@ class AnimationTrackEditor : public VBoxContainer {
void _insert_key_from_track(float p_ofs, int p_track);
void _add_method_key(const String &p_method);

void _clear_selection(bool p_update = false);
void _clear_selection_for_anim(const Ref<Animation> &p_anim);
void _select_at_anim(const Ref<Animation> &p_anim, int p_track, float p_pos);

Expand All @@ -425,9 +423,6 @@ class AnimationTrackEditor : public VBoxContainer {

RBMap<SelectedKey, KeyInfo> selection;

void _key_selected(int p_key, bool p_single, int p_track);
void _key_deselected(int p_key, int p_track);

bool moving_selection = false;
float moving_selection_offset = 0.0f;
void _move_selection_begin();
Expand Down Expand Up @@ -531,6 +526,11 @@ class AnimationTrackEditor : public VBoxContainer {
void _notification(int p_what);

public:
// Public for use with callable_mp.
void _clear_selection(bool p_update = false);
void _key_selected(int p_key, bool p_single, int p_track);
void _key_deselected(int p_key, int p_track);

enum {
EDIT_COPY_TRACKS,
EDIT_COPY_TRACKS_CONFIRM,
Expand Down
2 changes: 1 addition & 1 deletion editor/connections_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ void ConnectionsDock::_go_to_script(TreeItem &p_item) {
}

if (script.is_valid() && ScriptEditor::get_singleton()->script_goto_method(script, cd.method)) {
EditorNode::get_singleton()->call("_editor_select", EditorNode::EDITOR_SCRIPT);
EditorNode::get_singleton()->editor_select(EditorNode::EDITOR_SCRIPT);
}
}

Expand Down
4 changes: 3 additions & 1 deletion editor/editor_file_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ class EditorFileDialog : public ConfirmationDialog {

void _select_drive(int p_idx);
void _dir_submitted(String p_dir);
void _file_submitted(const String &p_file);
void _action_pressed();
void _save_confirm_pressed();
void _cancel_pressed();
Expand Down Expand Up @@ -240,6 +239,9 @@ class EditorFileDialog : public ConfirmationDialog {
static void _bind_methods();

public:
// Public for use with callable_mp.
void _file_submitted(const String &p_file);

void popup_file_dialog();
void clear_filters();
void add_filter(const String &p_filter, const String &p_description = "");
Expand Down
54 changes: 18 additions & 36 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,15 @@ void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) {
}

if (ED_IS_SHORTCUT("editor/editor_2d", p_event)) {
_editor_select(EDITOR_2D);
editor_select(EDITOR_2D);
} else if (ED_IS_SHORTCUT("editor/editor_3d", p_event)) {
_editor_select(EDITOR_3D);
editor_select(EDITOR_3D);
} else if (ED_IS_SHORTCUT("editor/editor_script", p_event)) {
_editor_select(EDITOR_SCRIPT);
editor_select(EDITOR_SCRIPT);
} else if (ED_IS_SHORTCUT("editor/editor_help", p_event)) {
emit_signal(SNAME("request_help_search"), "");
} else if (ED_IS_SHORTCUT("editor/editor_assetlib", p_event) && AssetLibraryEditorPlugin::is_available()) {
_editor_select(EDITOR_ASSETLIB);
editor_select(EDITOR_ASSETLIB);
} else if (ED_IS_SHORTCUT("editor/editor_next", p_event)) {
_editor_select_next();
} else if (ED_IS_SHORTCUT("editor/editor_prev", p_event)) {
Expand Down Expand Up @@ -584,7 +584,7 @@ void EditorNode::_update_from_settings() {
void EditorNode::_select_default_main_screen_plugin() {
if (EDITOR_3D < main_editor_buttons.size() && main_editor_buttons[EDITOR_3D]->is_visible()) {
// If the 3D editor is enabled, use this as the default.
_editor_select(EDITOR_3D);
editor_select(EDITOR_3D);
return;
}

Expand All @@ -593,12 +593,12 @@ void EditorNode::_select_default_main_screen_plugin() {
for (int i = 0; i < main_editor_buttons.size(); i++) {
Button *editor_button = main_editor_buttons[i];
if (editor_button->is_visible()) {
_editor_select(i);
editor_select(i);
return;
}
}

_editor_select(-1);
editor_select(-1);
}

void EditorNode::_notification(int p_what) {
Expand Down Expand Up @@ -1190,7 +1190,7 @@ void EditorNode::_editor_select_next() {
}
} while (!main_editor_buttons[editor]->is_visible());

_editor_select(editor);
editor_select(editor);
}

void EditorNode::_open_command_palette() {
Expand All @@ -1208,7 +1208,7 @@ void EditorNode::_editor_select_prev() {
}
} while (!main_editor_buttons[editor]->is_visible());

_editor_select(editor);
editor_select(editor);
}

Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_deps) {
Expand Down Expand Up @@ -2390,7 +2390,7 @@ void EditorNode::_edit_current(bool p_skip_foreign) {

else if (main_plugin != editor_plugin_screen && (!ScriptEditor::get_singleton() || !ScriptEditor::get_singleton()->is_visible_in_tree() || ScriptEditor::get_singleton()->can_take_away_focus())) {
// Update screen main_plugin.
_editor_select(plugin_index);
editor_select(plugin_index);
main_plugin->edit(current_obj);
} else {
editor_plugin_screen->edit(current_obj);
Expand Down Expand Up @@ -3303,7 +3303,7 @@ VBoxContainer *EditorNode::get_main_screen_control() {
return main_screen_vbox;
}

void EditorNode::_editor_select(int p_which) {
void EditorNode::editor_select(int p_which) {
static bool selecting = false;
if (selecting || changing_scene) {
return;
Expand Down Expand Up @@ -3357,7 +3357,7 @@ void EditorNode::select_editor_by_name(const String &p_name) {

for (int i = 0; i < main_editor_buttons.size(); i++) {
if (main_editor_buttons[i]->get_text() == p_name) {
_editor_select(i);
editor_select(i);
return;
}
}
Expand All @@ -3370,7 +3370,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
Button *tb = memnew(Button);
tb->set_flat(true);
tb->set_toggle_mode(true);
tb->connect("pressed", callable_mp(singleton, &EditorNode::_editor_select).bind(singleton->main_editor_buttons.size()));
tb->connect("pressed", callable_mp(singleton, &EditorNode::editor_select).bind(singleton->main_editor_buttons.size()));
tb->set_name(p_editor->get_name());
tb->set_text(p_editor->get_name());

Expand Down Expand Up @@ -3404,7 +3404,7 @@ void EditorNode::remove_editor_plugin(EditorPlugin *p_editor, bool p_config_chan
for (int i = 0; i < singleton->main_editor_buttons.size(); i++) {
if (p_editor->get_name() == singleton->main_editor_buttons[i]->get_text()) {
if (singleton->main_editor_buttons[i]->is_pressed()) {
singleton->_editor_select(EDITOR_SCRIPT);
singleton->editor_select(EDITOR_SCRIPT);
}

memdelete(singleton->main_editor_buttons[i]);
Expand Down Expand Up @@ -3628,7 +3628,7 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
int index = p_state["editor_index"];
if (current < 2) { // If currently in spatial/2d, only switch to spatial/2d. If currently in script, stay there.
if (index < 2 || !get_edited_scene()) {
_editor_select(index);
editor_select(index);
}
}
}
Expand All @@ -3639,9 +3639,9 @@ void EditorNode::_set_main_scene_state(Dictionary p_state, Node *p_for_scene) {
int n2d = 0, n3d = 0;
_find_node_types(get_edited_scene(), n2d, n3d);
if (n2d > n3d) {
_editor_select(EDITOR_2D);
editor_select(EDITOR_2D);
} else if (n3d > n2d) {
_editor_select(EDITOR_3D);
editor_select(EDITOR_3D);
}
}
}
Expand All @@ -3668,10 +3668,6 @@ bool EditorNode::is_changing_scene() const {
return changing_scene;
}

void EditorNode::_clear_undo_history() {
get_undo_redo()->clear_history(false);
}

void EditorNode::set_current_scene(int p_idx) {
// Save the folding in case the scene gets reloaded.
if (editor_data.get_scene_path(p_idx) != "" && editor_data.get_edited_scene_root(p_idx)) {
Expand Down Expand Up @@ -5937,7 +5933,7 @@ void EditorNode::_feature_profile_changed() {
if ((profile->is_feature_disabled(EditorFeatureProfile::FEATURE_3D) && singleton->main_editor_buttons[EDITOR_3D]->is_pressed()) ||
(profile->is_feature_disabled(EditorFeatureProfile::FEATURE_SCRIPT) && singleton->main_editor_buttons[EDITOR_SCRIPT]->is_pressed()) ||
(AssetLibraryEditorPlugin::is_available() && profile->is_feature_disabled(EditorFeatureProfile::FEATURE_ASSET_LIB) && singleton->main_editor_buttons[EDITOR_ASSETLIB]->is_pressed())) {
_editor_select(EDITOR_2D);
editor_select(EDITOR_2D);
}
} else {
import_tabs->set_tab_hidden(import_tabs->get_tab_idx_from_control(ImportDock::get_singleton()), false);
Expand All @@ -5960,19 +5956,14 @@ void EditorNode::_bind_methods() {
GLOBAL_DEF("editor/scene/scene_naming", SCENE_NAME_CASING_SNAKE_CASE);
ProjectSettings::get_singleton()->set_custom_property_info("editor/scene/scene_naming", PropertyInfo(Variant::INT, "editor/scene/scene_naming", PROPERTY_HINT_ENUM, "Auto,PascalCase,snake_case"));
ClassDB::bind_method("edit_current", &EditorNode::edit_current);
ClassDB::bind_method("_editor_select", &EditorNode::_editor_select);
ClassDB::bind_method("_node_renamed", &EditorNode::_node_renamed);
ClassDB::bind_method("edit_node", &EditorNode::edit_node);

ClassDB::bind_method(D_METHOD("push_item", "object", "property", "inspector_only"), &EditorNode::push_item, DEFVAL(""), DEFVAL(false));

ClassDB::bind_method("_get_scene_metadata", &EditorNode::_get_scene_metadata);
ClassDB::bind_method("set_edited_scene", &EditorNode::set_edited_scene);
ClassDB::bind_method("open_request", &EditorNode::open_request);
ClassDB::bind_method("edit_foreign_resource", &EditorNode::edit_foreign_resource);
ClassDB::bind_method("is_resource_read_only", &EditorNode::is_resource_read_only);
ClassDB::bind_method("_close_messages", &EditorNode::_close_messages);
ClassDB::bind_method("_show_messages", &EditorNode::_show_messages);

ClassDB::bind_method("stop_child_process", &EditorNode::stop_child_process);

Expand All @@ -5981,19 +5972,10 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method("_set_main_scene_state", &EditorNode::_set_main_scene_state);
ClassDB::bind_method("_update_recent_scenes", &EditorNode::_update_recent_scenes);

ClassDB::bind_method("_clear_undo_history", &EditorNode::_clear_undo_history);

ClassDB::bind_method("edit_item_resource", &EditorNode::edit_item_resource);

ClassDB::bind_method(D_METHOD("get_gui_base"), &EditorNode::get_gui_base);

ClassDB::bind_method(D_METHOD("_on_plugin_ready"), &EditorNode::_on_plugin_ready); // Still used by some connect_compat.

ClassDB::bind_method("_screenshot", &EditorNode::_screenshot);
ClassDB::bind_method("_save_screenshot", &EditorNode::_save_screenshot);

ClassDB::bind_method("_version_button_pressed", &EditorNode::_version_button_pressed);

ADD_SIGNAL(MethodInfo("play_pressed"));
ADD_SIGNAL(MethodInfo("pause_pressed"));
ADD_SIGNAL(MethodInfo("stop_pressed"));
Expand Down
10 changes: 5 additions & 5 deletions editor/editor_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ class EditorNode : public Node {
void _update_file_menu_opened();
void _update_file_menu_closed();

void _on_plugin_ready(Object *p_script, const String &p_activate_name);
void _remove_plugin_from_enabled(const String &p_name);

void _fs_changed();
Expand All @@ -553,7 +552,6 @@ class EditorNode : public Node {
void _node_renamed();
void _editor_select_next();
void _editor_select_prev();
void _editor_select(int p_which);
void _set_scene_metadata(const String &p_file, int p_idx = -1);
void _get_scene_metadata(const String &p_file);
void _update_title();
Expand Down Expand Up @@ -658,8 +656,6 @@ class EditorNode : public Node {
void _update_layouts_menu();
void _layout_menu_option(int p_id);

void _clear_undo_history();

void _update_addon_config();

void _toggle_distraction_free_mode();
Expand Down Expand Up @@ -703,7 +699,11 @@ class EditorNode : public Node {
void set_current_tab(int p_tab);

public:
void set_visible_editor(EditorTable p_table) { _editor_select(p_table); }
// Public for use with callable_mp.
void _on_plugin_ready(Object *p_script, const String &p_activate_name);

void editor_select(int p_which);
void set_visible_editor(EditorTable p_table) { editor_select(p_table); }

bool call_build();

Expand Down
2 changes: 1 addition & 1 deletion editor/editor_plugin_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void EditorPluginSettings::_notification(int p_what) {
} break;

case Node::NOTIFICATION_READY: {
plugin_config_dialog->connect("plugin_ready", Callable(EditorNode::get_singleton(), "_on_plugin_ready"));
plugin_config_dialog->connect("plugin_ready", callable_mp(EditorNode::get_singleton(), &EditorNode::_on_plugin_ready));
plugin_list->connect("button_clicked", callable_mp(this, &EditorPluginSettings::_cell_button_pressed));
} break;
}
Expand Down
8 changes: 4 additions & 4 deletions editor/export/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,10 @@ void ProjectExportDialog::_validate_export_path(const String &p_path) {

if (invalid_path) {
export_project->get_ok_button()->set_disabled(true);
export_project->get_line_edit()->disconnect("text_submitted", Callable(export_project, "_file_submitted"));
export_project->get_line_edit()->disconnect("text_submitted", callable_mp(export_project, &EditorFileDialog::_file_submitted));
} else {
export_project->get_ok_button()->set_disabled(false);
export_project->get_line_edit()->connect("text_submitted", Callable(export_project, "_file_submitted"));
export_project->get_line_edit()->connect("text_submitted", callable_mp(export_project, &EditorFileDialog::_file_submitted));
}
}

Expand Down Expand Up @@ -901,9 +901,9 @@ void ProjectExportDialog::_export_project() {
// with _validate_export_path.
// FIXME: This is a hack, we should instead change EditorFileDialog to allow
// disabling validation by the "text_submitted" signal.
if (!export_project->get_line_edit()->is_connected("text_submitted", Callable(export_project, "_file_submitted"))) {
if (!export_project->get_line_edit()->is_connected("text_submitted", callable_mp(export_project, &EditorFileDialog::_file_submitted))) {
export_project->get_ok_button()->set_disabled(false);
export_project->get_line_edit()->connect("text_submitted", Callable(export_project, "_file_submitted"));
export_project->get_line_edit()->connect("text_submitted", callable_mp(export_project, &EditorFileDialog::_file_submitted));
}

export_project->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
Expand Down
Loading

0 comments on commit 882a4f8

Please sign in to comment.