diff options
64 files changed, 213 insertions, 110 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp index 5137930116..4172793f9d 100644 --- a/core/core_bind.cpp +++ b/core/core_bind.cpp @@ -116,6 +116,11 @@ bool ResourceLoader::has_cached(const String &p_path) { return ResourceCache::has(local_path); } +Ref<Resource> ResourceLoader::get_cached_ref(const String &p_path) { + String local_path = ProjectSettings::get_singleton()->localize_path(p_path); + return ResourceCache::get_ref(local_path); +} + bool ResourceLoader::exists(const String &p_path, const String &p_type_hint) { return ::ResourceLoader::exists(p_path, p_type_hint); } @@ -136,6 +141,7 @@ void ResourceLoader::_bind_methods() { ClassDB::bind_method(D_METHOD("set_abort_on_missing_resources", "abort"), &ResourceLoader::set_abort_on_missing_resources); ClassDB::bind_method(D_METHOD("get_dependencies", "path"), &ResourceLoader::get_dependencies); ClassDB::bind_method(D_METHOD("has_cached", "path"), &ResourceLoader::has_cached); + ClassDB::bind_method(D_METHOD("get_cached_ref", "path"), &ResourceLoader::get_cached_ref); ClassDB::bind_method(D_METHOD("exists", "path", "type_hint"), &ResourceLoader::exists, DEFVAL("")); ClassDB::bind_method(D_METHOD("get_resource_uid", "path"), &ResourceLoader::get_resource_uid); diff --git a/core/core_bind.h b/core/core_bind.h index e953483391..122963e634 100644 --- a/core/core_bind.h +++ b/core/core_bind.h @@ -83,6 +83,7 @@ public: void set_abort_on_missing_resources(bool p_abort); PackedStringArray get_dependencies(const String &p_path); bool has_cached(const String &p_path); + Ref<Resource> get_cached_ref(const String &p_path); bool exists(const String &p_path, const String &p_type_hint = ""); ResourceUID::ID get_resource_uid(const String &p_path); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index d755b7f9dc..3e809ae762 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -539,6 +539,11 @@ Ref<ResourceLoader::LoadToken> ResourceLoader::_load_start(const String &p_path, if (!ignoring_cache && thread_load_tasks.has(local_path)) { load_token = Ref<LoadToken>(thread_load_tasks[local_path].load_token); if (load_token.is_valid()) { + if (p_for_user) { + // Load task exists, with no user tokens at the moment. + // Let's "attach" to it. + _load_threaded_request_setup_user_token(load_token.ptr(), p_path); + } return load_token; } else { // The token is dying (reached 0 on another thread). diff --git a/core/object/worker_thread_pool.cpp b/core/object/worker_thread_pool.cpp index 7fd43c4094..25ad3bf964 100644 --- a/core/object/worker_thread_pool.cpp +++ b/core/object/worker_thread_pool.cpp @@ -461,7 +461,10 @@ void WorkerThreadPool::_wait_collaboratively(ThreadData *p_caller_pool_thread, T p_caller_pool_thread->signaled = false; if (IS_WAIT_OVER) { - p_caller_pool_thread->yield_is_over = false; + if (unlikely(p_task == ThreadData::YIELDING)) { + p_caller_pool_thread->yield_is_over = false; + } + if (!exit_threads && was_signaled) { // This thread was awaken for some additional reason, but it's about to exit. // Let's find out what may be pending and forward the requests. diff --git a/core/variant/binder_common.h b/core/variant/binder_common.h index 61b90e2a26..fa49767d46 100644 --- a/core/variant/binder_common.h +++ b/core/variant/binder_common.h @@ -214,11 +214,11 @@ struct VariantCaster<char32_t> { template <> struct PtrToArg<char32_t> { _FORCE_INLINE_ static char32_t convert(const void *p_ptr) { - return char32_t(*reinterpret_cast<const int *>(p_ptr)); + return char32_t(*reinterpret_cast<const int64_t *>(p_ptr)); } typedef int64_t EncodeT; _FORCE_INLINE_ static void encode(char32_t p_val, const void *p_ptr) { - *(int *)p_ptr = p_val; + *(int64_t *)p_ptr = p_val; } }; diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml index cb0db46595..56c3208fc3 100644 --- a/doc/classes/ResourceLoader.xml +++ b/doc/classes/ResourceLoader.xml @@ -31,6 +31,14 @@ [b]Note:[/b] If you use [method Resource.take_over_path], this method will return [code]true[/code] for the taken path even if the resource wasn't saved (i.e. exists only in resource cache). </description> </method> + <method name="get_cached_ref"> + <return type="Resource" /> + <param index="0" name="path" type="String" /> + <description> + Returns the cached resource reference for the given [param path]. + [b]Note:[/b] If the resource is not cached, the returned [Resource] will be invalid. + </description> + </method> <method name="get_dependencies"> <return type="PackedStringArray" /> <param index="0" name="path" type="String" /> diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp index 6b237366fd..16423fb111 100644 --- a/editor/action_map_editor.cpp +++ b/editor/action_map_editor.cpp @@ -584,7 +584,7 @@ ActionMapEditor::ActionMapEditor() { show_builtin_actions_checkbutton = memnew(CheckButton); show_builtin_actions_checkbutton->set_text(TTR("Show Built-in Actions")); - show_builtin_actions_checkbutton->connect("toggled", callable_mp(this, &ActionMapEditor::set_show_builtin_actions)); + show_builtin_actions_checkbutton->connect(SceneStringName(toggled), callable_mp(this, &ActionMapEditor::set_show_builtin_actions)); add_hbox->add_child(show_builtin_actions_checkbutton); show_builtin_actions = EditorSettings::get_singleton()->get_project_metadata("project_settings", "show_builtin_actions", false); diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 180c25c34f..dd8aa523c4 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -755,13 +755,13 @@ FindReplaceBar::FindReplaceBar() { hbc_option_search->add_child(case_sensitive); case_sensitive->set_text(TTR("Match Case")); case_sensitive->set_focus_mode(FOCUS_NONE); - case_sensitive->connect("toggled", callable_mp(this, &FindReplaceBar::_search_options_changed)); + case_sensitive->connect(SceneStringName(toggled), callable_mp(this, &FindReplaceBar::_search_options_changed)); whole_words = memnew(CheckBox); hbc_option_search->add_child(whole_words); whole_words->set_text(TTR("Whole Words")); whole_words->set_focus_mode(FOCUS_NONE); - whole_words->connect("toggled", callable_mp(this, &FindReplaceBar::_search_options_changed)); + whole_words->connect(SceneStringName(toggled), callable_mp(this, &FindReplaceBar::_search_options_changed)); // Replace toolbar replace_text = memnew(LineEdit); @@ -786,7 +786,7 @@ FindReplaceBar::FindReplaceBar() { hbc_option_replace->add_child(selection_only); selection_only->set_text(TTR("Selection Only")); selection_only->set_focus_mode(FOCUS_NONE); - selection_only->connect("toggled", callable_mp(this, &FindReplaceBar::_search_options_changed)); + selection_only->connect(SceneStringName(toggled), callable_mp(this, &FindReplaceBar::_search_options_changed)); hide_button = memnew(TextureButton); add_child(hide_button); @@ -1548,7 +1548,8 @@ void CodeTextEditor::_set_show_warnings_panel(bool p_show) { } void CodeTextEditor::_toggle_scripts_pressed() { - ScriptEditor::get_singleton()->toggle_scripts_panel(); + ERR_FAIL_NULL(toggle_scripts_list); + toggle_scripts_list->set_visible(!toggle_scripts_list->is_visible()); update_toggle_scripts_button(); } @@ -1723,16 +1724,18 @@ void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_cod code_complete_ud = p_ud; } +void CodeTextEditor::set_toggle_list_control(Control *p_control) { + toggle_scripts_list = p_control; +} + void CodeTextEditor::show_toggle_scripts_button() { toggle_scripts_button->show(); } void CodeTextEditor::update_toggle_scripts_button() { - if (is_layout_rtl()) { - toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Forward") : SNAME("Back"))); - } else { - toggle_scripts_button->set_icon(get_editor_theme_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? SNAME("Back") : SNAME("Forward"))); - } + ERR_FAIL_NULL(toggle_scripts_list); + bool forward = toggle_scripts_list->is_visible() == is_layout_rtl(); + toggle_scripts_button->set_icon(get_editor_theme_icon(forward ? SNAME("Forward") : SNAME("Back"))); toggle_scripts_button->set_tooltip_text(vformat("%s (%s)", TTR("Toggle Scripts Panel"), ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text())); } diff --git a/editor/code_editor.h b/editor/code_editor.h index d209d5c7a2..e56405a4b2 100644 --- a/editor/code_editor.h +++ b/editor/code_editor.h @@ -161,6 +161,7 @@ class CodeTextEditor : public VBoxContainer { HBoxContainer *status_bar = nullptr; Button *toggle_scripts_button = nullptr; + Control *toggle_scripts_list = nullptr; Button *error_button = nullptr; Button *warning_button = nullptr; @@ -285,6 +286,7 @@ public: void validate_script(); + void set_toggle_list_control(Control *p_control); void show_toggle_scripts_button(); void update_toggle_scripts_button(); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index b415c72c15..1e44a9bdc9 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -685,7 +685,7 @@ EditorAssetInstaller::EditorAssetInstaller() { show_source_files_button->set_toggle_mode(true); show_source_files_button->set_tooltip_text(TTR("Open the list of the asset contents and select which files to install.")); remapping_tools->add_child(show_source_files_button); - show_source_files_button->connect("toggled", callable_mp(this, &EditorAssetInstaller::_toggle_source_tree).bind(false)); + show_source_files_button->connect(SceneStringName(toggled), callable_mp(this, &EditorAssetInstaller::_toggle_source_tree).bind(false)); Button *target_dir_button = memnew(Button); target_dir_button->set_text(TTR("Change Install Folder")); @@ -698,7 +698,7 @@ EditorAssetInstaller::EditorAssetInstaller() { skip_toplevel_check = memnew(CheckBox); skip_toplevel_check->set_text(TTR("Ignore asset root")); skip_toplevel_check->set_tooltip_text(TTR("Ignore the root directory when extracting files.")); - skip_toplevel_check->connect("toggled", callable_mp(this, &EditorAssetInstaller::_set_skip_toplevel)); + skip_toplevel_check->connect(SceneStringName(toggled), callable_mp(this, &EditorAssetInstaller::_set_skip_toplevel)); remapping_tools->add_child(skip_toplevel_check); remapping_tools->add_spacer(); diff --git a/editor/editor_locale_dialog.cpp b/editor/editor_locale_dialog.cpp index 83f1c70c69..c36792c9e3 100644 --- a/editor/editor_locale_dialog.cpp +++ b/editor/editor_locale_dialog.cpp @@ -408,7 +408,7 @@ EditorLocaleDialog::EditorLocaleDialog() { edit_filters->set_text(TTR("Edit Filters")); edit_filters->set_toggle_mode(true); edit_filters->set_pressed(false); - edit_filters->connect("toggled", callable_mp(this, &EditorLocaleDialog::_edit_filters)); + edit_filters->connect(SceneStringName(toggled), callable_mp(this, &EditorLocaleDialog::_edit_filters)); hb_filter->add_child(edit_filters); } { @@ -416,7 +416,7 @@ EditorLocaleDialog::EditorLocaleDialog() { advanced->set_text(TTR("Advanced")); advanced->set_toggle_mode(true); advanced->set_pressed(false); - advanced->connect("toggled", callable_mp(this, &EditorLocaleDialog::_toggle_advanced)); + advanced->connect(SceneStringName(toggled), callable_mp(this, &EditorLocaleDialog::_toggle_advanced)); hb_filter->add_child(advanced); } vb->add_child(hb_filter); diff --git a/editor/editor_log.cpp b/editor/editor_log.cpp index 2c30cb8265..aec374929e 100644 --- a/editor/editor_log.cpp +++ b/editor/editor_log.cpp @@ -510,7 +510,7 @@ EditorLog::EditorLog() { collapse_button->set_tooltip_text(TTR("Collapse duplicate messages into one log entry. Shows number of occurrences.")); collapse_button->set_toggle_mode(true); collapse_button->set_pressed(false); - collapse_button->connect("toggled", callable_mp(this, &EditorLog::_set_collapse)); + collapse_button->connect(SceneStringName(toggled), callable_mp(this, &EditorLog::_set_collapse)); hb_tools2->add_child(collapse_button); // Show Search. @@ -521,7 +521,7 @@ EditorLog::EditorLog() { show_search_button->set_pressed(true); show_search_button->set_shortcut(ED_SHORTCUT("editor/open_search", TTR("Focus Search/Filter Bar"), KeyModifierMask::CMD_OR_CTRL | Key::F)); show_search_button->set_shortcut_context(this); - show_search_button->connect("toggled", callable_mp(this, &EditorLog::_set_search_visible)); + show_search_button->connect(SceneStringName(toggled), callable_mp(this, &EditorLog::_set_search_visible)); hb_tools2->add_child(show_search_button); // Message Type Filters. diff --git a/editor/editor_log.h b/editor/editor_log.h index 9c652e912a..899b4a9ac4 100644 --- a/editor/editor_log.h +++ b/editor/editor_log.h @@ -102,7 +102,7 @@ private: toggle_button->add_theme_color_override("icon_color_pressed", Color(1, 1, 1, 1)); toggle_button->set_focus_mode(FOCUS_NONE); // When toggled call the callback and pass the MessageType this button is for. - toggle_button->connect("toggled", p_toggled_callback.bind(type)); + toggle_button->connect(SceneStringName(toggled), p_toggled_callback.bind(type)); } int get_message_count() { diff --git a/editor/editor_properties_vector.cpp b/editor/editor_properties_vector.cpp index 365cbc6ec8..a40055cf85 100644 --- a/editor/editor_properties_vector.cpp +++ b/editor/editor_properties_vector.cpp @@ -236,7 +236,7 @@ EditorPropertyVectorN::EditorPropertyVectorN(Variant::Type p_type, bool p_force_ linked->set_stretch_mode(TextureButton::STRETCH_KEEP_CENTERED); linked->set_tooltip_text(TTR("Lock/Unlock Component Ratio")); linked->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyVectorN::_update_ratio)); - linked->connect(SNAME("toggled"), callable_mp(this, &EditorPropertyVectorN::_store_link)); + linked->connect(SceneStringName(toggled), callable_mp(this, &EditorPropertyVectorN::_store_link)); hb->add_child(linked); add_child(hb); diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp index 351afa3810..03e9fba12d 100644 --- a/editor/export/project_export.cpp +++ b/editor/export/project_export.cpp @@ -1410,12 +1410,12 @@ ProjectExportDialog::ProjectExportDialog() { sec_scroll_container->add_child(sec_vb); enc_pck = memnew(CheckButton); - enc_pck->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_pck_changed)); + enc_pck->connect(SceneStringName(toggled), callable_mp(this, &ProjectExportDialog::_enc_pck_changed)); enc_pck->set_text(TTR("Encrypt Exported PCK")); sec_vb->add_child(enc_pck); enc_directory = memnew(CheckButton); - enc_directory->connect("toggled", callable_mp(this, &ProjectExportDialog::_enc_directory_changed)); + enc_directory->connect(SceneStringName(toggled), callable_mp(this, &ProjectExportDialog::_enc_directory_changed)); enc_directory->set_text(TTR("Encrypt Index (File Names and Info)")); sec_vb->add_child(enc_directory); diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp index a5f7e8556c..ce2dbe7cb1 100644 --- a/editor/groups_editor.cpp +++ b/editor/groups_editor.cpp @@ -648,7 +648,7 @@ void GroupsEditor::_show_add_group_dialog() { add_group_description->set_editable(false); gc->add_child(add_group_description); - global_group_button->connect("toggled", callable_mp(add_group_description, &LineEdit::set_editable)); + global_group_button->connect(SceneStringName(toggled), callable_mp(add_group_description, &LineEdit::set_editable)); add_group_dialog->register_text_enter(add_group_name); add_group_dialog->register_text_enter(add_group_description); diff --git a/editor/gui/editor_bottom_panel.cpp b/editor/gui/editor_bottom_panel.cpp index 3cb95a3926..4b2fd9cb2f 100644 --- a/editor/gui/editor_bottom_panel.cpp +++ b/editor/gui/editor_bottom_panel.cpp @@ -158,7 +158,7 @@ void EditorBottomPanel::load_layout_from_config(Ref<ConfigFile> p_config_file, c Button *EditorBottomPanel::add_item(String p_text, Control *p_item, const Ref<Shortcut> &p_shortcut, bool p_at_front) { Button *tb = memnew(Button); tb->set_theme_type_variation("BottomPanelButton"); - tb->connect("toggled", callable_mp(this, &EditorBottomPanel::_switch_by_control).bind(p_item)); + tb->connect(SceneStringName(toggled), callable_mp(this, &EditorBottomPanel::_switch_by_control).bind(p_item)); tb->set_drag_forwarding(Callable(), callable_mp(this, &EditorBottomPanel::_button_drag_hover).bind(tb, p_item), Callable()); tb->set_text(p_text); tb->set_shortcut(p_shortcut); @@ -295,5 +295,5 @@ EditorBottomPanel::EditorBottomPanel() { expand_button->set_theme_type_variation("FlatMenuButton"); expand_button->set_toggle_mode(true); expand_button->set_shortcut(ED_SHORTCUT_AND_COMMAND("editor/bottom_panel_expand", TTR("Expand Bottom Panel"), KeyModifierMask::SHIFT | Key::F12)); - expand_button->connect("toggled", callable_mp(this, &EditorBottomPanel::_expand_button_toggled)); + expand_button->connect(SceneStringName(toggled), callable_mp(this, &EditorBottomPanel::_expand_button_toggled)); } diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index afc6d58d63..7aa19509e1 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -1779,7 +1779,7 @@ void EditorFileDialog::_update_option_controls() { CheckBox *cb = memnew(CheckBox); cb->set_pressed(opt.default_idx); grid_options->add_child(cb); - cb->connect("toggled", callable_mp(this, &EditorFileDialog::_option_changed_checkbox_toggled).bind(opt.name)); + cb->connect(SceneStringName(toggled), callable_mp(this, &EditorFileDialog::_option_changed_checkbox_toggled).bind(opt.name)); selected_options[opt.name] = (bool)opt.default_idx; } else { OptionButton *ob = memnew(OptionButton); @@ -2146,7 +2146,7 @@ EditorFileDialog::EditorFileDialog() { show_hidden->set_toggle_mode(true); show_hidden->set_pressed(is_showing_hidden_files()); show_hidden->set_tooltip_text(TTR("Toggle the visibility of hidden files.")); - show_hidden->connect("toggled", callable_mp(this, &EditorFileDialog::set_show_hidden_files)); + show_hidden->connect(SceneStringName(toggled), callable_mp(this, &EditorFileDialog::set_show_hidden_files)); pathhb->add_child(show_hidden); pathhb->add_child(memnew(VSeparator)); diff --git a/editor/gui/editor_run_bar.cpp b/editor/gui/editor_run_bar.cpp index 4cc2d1145e..9050ee0cd4 100644 --- a/editor/gui/editor_run_bar.cpp +++ b/editor/gui/editor_run_bar.cpp @@ -445,7 +445,7 @@ EditorRunBar::EditorRunBar() { write_movie_button->set_pressed(false); write_movie_button->set_focus_mode(Control::FOCUS_NONE); write_movie_button->set_tooltip_text(TTR("Enable Movie Maker mode.\nThe project will run at stable FPS and the visual and audio output will be recorded to a video file.")); - write_movie_button->connect("toggled", callable_mp(this, &EditorRunBar::_write_movie_toggled)); + write_movie_button->connect(SceneStringName(toggled), callable_mp(this, &EditorRunBar::_write_movie_toggled)); quick_run = memnew(EditorQuickOpen); add_child(quick_run); diff --git a/editor/gui/scene_tree_editor.cpp b/editor/gui/scene_tree_editor.cpp index 69ab9810a0..52ba98b4d5 100644 --- a/editor/gui/scene_tree_editor.cpp +++ b/editor/gui/scene_tree_editor.cpp @@ -1769,7 +1769,7 @@ SceneTreeDialog::SceneTreeDialog() { // Add 'Show All' button to HBoxContainer next to the filter, visible only when valid_types is defined. show_all_nodes = memnew(CheckButton); show_all_nodes->set_text(TTR("Show All")); - show_all_nodes->connect("toggled", callable_mp(this, &SceneTreeDialog::_show_all_nodes_changed)); + show_all_nodes->connect(SceneStringName(toggled), callable_mp(this, &SceneTreeDialog::_show_all_nodes_changed)); show_all_nodes->set_h_size_flags(Control::SIZE_SHRINK_BEGIN); show_all_nodes->hide(); filter_hbc->add_child(show_all_nodes); diff --git a/editor/history_dock.cpp b/editor/history_dock.cpp index 5a64fba788..1a0971a15c 100644 --- a/editor/history_dock.cpp +++ b/editor/history_dock.cpp @@ -245,8 +245,8 @@ HistoryDock::HistoryDock() { current_scene_checkbox->set_text(TTR("Scene")); current_scene_checkbox->set_h_size_flags(SIZE_EXPAND_FILL); current_scene_checkbox->set_clip_text(true); - current_scene_checkbox->connect("toggled", callable_mp(this, &HistoryDock::refresh_history).unbind(1)); - current_scene_checkbox->connect("toggled", callable_mp(this, &HistoryDock::save_options).unbind(1)); + current_scene_checkbox->connect(SceneStringName(toggled), callable_mp(this, &HistoryDock::refresh_history).unbind(1)); + current_scene_checkbox->connect(SceneStringName(toggled), callable_mp(this, &HistoryDock::save_options).unbind(1)); global_history_checkbox = memnew(CheckBox); mode_hb->add_child(global_history_checkbox); @@ -255,8 +255,8 @@ HistoryDock::HistoryDock() { global_history_checkbox->set_text(TTR("Global")); global_history_checkbox->set_h_size_flags(SIZE_EXPAND_FILL); global_history_checkbox->set_clip_text(true); - global_history_checkbox->connect("toggled", callable_mp(this, &HistoryDock::refresh_history).unbind(1)); - global_history_checkbox->connect("toggled", callable_mp(this, &HistoryDock::save_options).unbind(1)); + global_history_checkbox->connect(SceneStringName(toggled), callable_mp(this, &HistoryDock::refresh_history).unbind(1)); + global_history_checkbox->connect(SceneStringName(toggled), callable_mp(this, &HistoryDock::save_options).unbind(1)); action_list = memnew(ItemList); action_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); diff --git a/editor/import/audio_stream_import_settings.cpp b/editor/import/audio_stream_import_settings.cpp index a53deefee9..9a0c62193c 100644 --- a/editor/import/audio_stream_import_settings.cpp +++ b/editor/import/audio_stream_import_settings.cpp @@ -537,7 +537,7 @@ AudioStreamImportSettingsDialog::AudioStreamImportSettingsDialog() { loop = memnew(CheckBox); loop->set_text(TTR("Enable")); loop->set_tooltip_text(TTR("Enable looping.")); - loop->connect("toggled", callable_mp(this, &AudioStreamImportSettingsDialog::_settings_changed).unbind(1)); + loop->connect(SceneStringName(toggled), callable_mp(this, &AudioStreamImportSettingsDialog::_settings_changed).unbind(1)); loop_hb->add_child(loop); loop_hb->add_spacer(); loop_hb->add_child(memnew(Label(TTR("Offset:")))); @@ -554,7 +554,7 @@ AudioStreamImportSettingsDialog::AudioStreamImportSettingsDialog() { interactive_hb->add_theme_constant_override("separation", 4 * EDSCALE); bpm_enabled = memnew(CheckBox); bpm_enabled->set_text((TTR("BPM:"))); - bpm_enabled->connect("toggled", callable_mp(this, &AudioStreamImportSettingsDialog::_settings_changed).unbind(1)); + bpm_enabled->connect(SceneStringName(toggled), callable_mp(this, &AudioStreamImportSettingsDialog::_settings_changed).unbind(1)); interactive_hb->add_child(bpm_enabled); bpm_edit = memnew(SpinBox); bpm_edit->set_max(400); @@ -565,7 +565,7 @@ AudioStreamImportSettingsDialog::AudioStreamImportSettingsDialog() { interactive_hb->add_spacer(); beats_enabled = memnew(CheckBox); beats_enabled->set_text(TTR("Beat Count:")); - beats_enabled->connect("toggled", callable_mp(this, &AudioStreamImportSettingsDialog::_settings_changed).unbind(1)); + beats_enabled->connect(SceneStringName(toggled), callable_mp(this, &AudioStreamImportSettingsDialog::_settings_changed).unbind(1)); interactive_hb->add_child(beats_enabled); beats_edit = memnew(SpinBox); beats_edit->set_tooltip_text(TTR("Configure the amount of Beats used for music-aware looping. If zero, it will be autodetected from the length.\nIt is recommended to set this value (either manually or by clicking on a beat number in the preview) to ensure looping works properly.")); diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp index dc839b02f6..c60197b96b 100644 --- a/editor/input_event_configuration_dialog.cpp +++ b/editor/input_event_configuration_dialog.cpp @@ -720,7 +720,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { for (int i = 0; i < MOD_MAX; i++) { String name = mods[i]; mod_checkboxes[i] = memnew(CheckBox); - mod_checkboxes[i]->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_mod_toggled).bind(i)); + mod_checkboxes[i]->connect(SceneStringName(toggled), callable_mp(this, &InputEventConfigurationDialog::_mod_toggled).bind(i)); mod_checkboxes[i]->set_text(name); mod_checkboxes[i]->set_tooltip_text(TTR(mods_tip[i])); mod_container->add_child(mod_checkboxes[i]); @@ -729,7 +729,7 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() { mod_container->add_child(memnew(VSeparator)); autoremap_command_or_control_checkbox = memnew(CheckBox); - autoremap_command_or_control_checkbox->connect("toggled", callable_mp(this, &InputEventConfigurationDialog::_autoremap_command_or_control_toggled)); + autoremap_command_or_control_checkbox->connect(SceneStringName(toggled), callable_mp(this, &InputEventConfigurationDialog::_autoremap_command_or_control_toggled)); autoremap_command_or_control_checkbox->set_pressed(false); autoremap_command_or_control_checkbox->set_text(TTR("Command / Control (auto)")); autoremap_command_or_control_checkbox->set_tooltip_text(TTR("Automatically remaps between 'Meta' ('Command') and 'Control' depending on current platform.")); diff --git a/editor/plugins/animation_blend_space_1d_editor.cpp b/editor/plugins/animation_blend_space_1d_editor.cpp index 7d580e8de9..cbf8b27b32 100644 --- a/editor/plugins/animation_blend_space_1d_editor.cpp +++ b/editor/plugins/animation_blend_space_1d_editor.cpp @@ -713,7 +713,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() { top_hb->add_child(memnew(Label(TTR("Sync:")))); sync = memnew(CheckBox); top_hb->add_child(sync); - sync->connect("toggled", callable_mp(this, &AnimationNodeBlendSpace1DEditor::_config_changed)); + sync->connect(SceneStringName(toggled), callable_mp(this, &AnimationNodeBlendSpace1DEditor::_config_changed)); top_hb->add_child(memnew(VSeparator)); diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 55949df54f..934f26415a 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -961,7 +961,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() { top_hb->add_child(memnew(Label(TTR("Sync:")))); sync = memnew(CheckBox); top_hb->add_child(sync); - sync->connect("toggled", callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed)); + sync->connect(SceneStringName(toggled), callable_mp(this, &AnimationNodeBlendSpace2DEditor::_config_changed)); top_hb->add_child(memnew(VSeparator)); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 8dad6d6dbd..ec42cb31be 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -5409,7 +5409,7 @@ CanvasItemEditor::CanvasItemEditor() { smart_snap_button->set_theme_type_variation("FlatButton"); main_menu_hbox->add_child(smart_snap_button); smart_snap_button->set_toggle_mode(true); - smart_snap_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_smart_snap)); + smart_snap_button->connect(SceneStringName(toggled), callable_mp(this, &CanvasItemEditor::_button_toggle_smart_snap)); smart_snap_button->set_tooltip_text(TTR("Toggle smart snapping.")); smart_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_smart_snap", TTR("Use Smart Snap"), KeyModifierMask::SHIFT | Key::S)); smart_snap_button->set_shortcut_context(this); @@ -5418,7 +5418,7 @@ CanvasItemEditor::CanvasItemEditor() { grid_snap_button->set_theme_type_variation("FlatButton"); main_menu_hbox->add_child(grid_snap_button); grid_snap_button->set_toggle_mode(true); - grid_snap_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_toggle_grid_snap)); + grid_snap_button->connect(SceneStringName(toggled), callable_mp(this, &CanvasItemEditor::_button_toggle_grid_snap)); grid_snap_button->set_tooltip_text(TTR("Toggle grid snapping.")); grid_snap_button->set_shortcut(ED_SHORTCUT("canvas_item_editor/use_grid_snap", TTR("Use Grid Snap"), KeyModifierMask::SHIFT | Key::G)); grid_snap_button->set_shortcut_context(this); @@ -5511,7 +5511,7 @@ CanvasItemEditor::CanvasItemEditor() { override_camera_button = memnew(Button); override_camera_button->set_theme_type_variation("FlatButton"); main_menu_hbox->add_child(override_camera_button); - override_camera_button->connect("toggled", callable_mp(this, &CanvasItemEditor::_button_override_camera)); + override_camera_button->connect(SceneStringName(toggled), callable_mp(this, &CanvasItemEditor::_button_override_camera)); override_camera_button->set_toggle_mode(true); override_camera_button->set_disabled(true); _update_override_camera_button(false); diff --git a/editor/plugins/control_editor_plugin.cpp b/editor/plugins/control_editor_plugin.cpp index df20395ac5..5c5f236ff3 100644 --- a/editor/plugins/control_editor_plugin.cpp +++ b/editor/plugins/control_editor_plugin.cpp @@ -1084,7 +1084,7 @@ ControlEditorToolbar::ControlEditorToolbar() { anchor_mode_button->set_toggle_mode(true); anchor_mode_button->set_tooltip_text(TTR("When active, moving Control nodes changes their anchors instead of their offsets.")); add_child(anchor_mode_button); - anchor_mode_button->connect("toggled", callable_mp(this, &ControlEditorToolbar::_anchor_mode_toggled)); + anchor_mode_button->connect(SceneStringName(toggled), callable_mp(this, &ControlEditorToolbar::_anchor_mode_toggled)); // Container tools. containers_button = memnew(ControlEditorPopupButton); diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 180de700b7..e518cf7815 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -1003,7 +1003,7 @@ CurveEditor::CurveEditor() { snap_button->set_tooltip_text(TTR("Toggle Grid Snap")); snap_button->set_toggle_mode(true); toolbar->add_child(snap_button); - snap_button->connect("toggled", callable_mp(this, &CurveEditor::_set_snap_enabled)); + snap_button->connect(SceneStringName(toggled), callable_mp(this, &CurveEditor::_set_snap_enabled)); toolbar->add_child(memnew(VSeparator)); diff --git a/editor/plugins/gradient_editor_plugin.cpp b/editor/plugins/gradient_editor_plugin.cpp index 8bf5dad97f..1300394ca3 100644 --- a/editor/plugins/gradient_editor_plugin.cpp +++ b/editor/plugins/gradient_editor_plugin.cpp @@ -632,7 +632,7 @@ GradientEditor::GradientEditor() { snap_button->set_tooltip_text(TTR("Toggle Grid Snap")); snap_button->set_toggle_mode(true); toolbar->add_child(snap_button); - snap_button->connect("toggled", callable_mp(this, &GradientEditor::_set_snap_enabled)); + snap_button->connect(SceneStringName(toggled), callable_mp(this, &GradientEditor::_set_snap_enabled)); snap_count_edit = memnew(EditorSpinSlider); snap_count_edit->set_min(2); diff --git a/editor/plugins/gradient_texture_2d_editor_plugin.cpp b/editor/plugins/gradient_texture_2d_editor_plugin.cpp index 7e22e1209c..5bf1422780 100644 --- a/editor/plugins/gradient_texture_2d_editor_plugin.cpp +++ b/editor/plugins/gradient_texture_2d_editor_plugin.cpp @@ -290,7 +290,7 @@ GradientTexture2DEditor::GradientTexture2DEditor() { snap_button->set_tooltip_text(TTR("Toggle Grid Snap")); snap_button->set_toggle_mode(true); toolbar->add_child(snap_button); - snap_button->connect("toggled", callable_mp(this, &GradientTexture2DEditor::_set_snap_enabled)); + snap_button->connect(SceneStringName(toggled), callable_mp(this, &GradientTexture2DEditor::_set_snap_enabled)); snap_count_edit = memnew(EditorSpinSlider); snap_count_edit->set_min(2); diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index f0be8791d3..8b0f4a64a7 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -3729,10 +3729,10 @@ void Node3DEditorViewport::_set_auto_orthogonal() { } void Node3DEditorViewport::_preview_exited_scene() { - preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); + preview_camera->disconnect(SceneStringName(toggled), callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); preview_camera->set_pressed(false); _toggle_camera_preview(false); - preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); + preview_camera->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); view_menu->show(); } @@ -4104,8 +4104,8 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { view_menu->get_popup()->set_item_checked(idx, previewing_cinema); } - if (preview_camera->is_connected("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview))) { - preview_camera->disconnect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); + if (preview_camera->is_connected(SceneStringName(toggled), callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview))) { + preview_camera->disconnect(SceneStringName(toggled), callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); } if (p_state.has("previewing")) { Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]); @@ -4118,7 +4118,7 @@ void Node3DEditorViewport::set_state(const Dictionary &p_state) { preview_camera->show(); } } - preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); + preview_camera->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); } Dictionary Node3DEditorViewport::get_state() const { @@ -5466,7 +5466,7 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p vbox->add_child(preview_camera); preview_camera->set_h_size_flags(0); preview_camera->hide(); - preview_camera->connect("toggled", callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); + preview_camera->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditorViewport::_toggle_camera_preview)); previewing = nullptr; gizmo_scale = 1.0; @@ -8681,7 +8681,7 @@ Node3DEditor::Node3DEditor() { main_menu_hbox->add_child(tool_option_button[TOOL_OPT_LOCAL_COORDS]); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_toggle_mode(true); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_theme_type_variation("FlatButton"); - tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_LOCAL_COORDS)); + tool_option_button[TOOL_OPT_LOCAL_COORDS]->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_LOCAL_COORDS)); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut(ED_SHORTCUT("spatial_editor/local_coords", TTR("Use Local Space"), Key::T)); tool_option_button[TOOL_OPT_LOCAL_COORDS]->set_shortcut_context(this); @@ -8689,7 +8689,7 @@ Node3DEditor::Node3DEditor() { main_menu_hbox->add_child(tool_option_button[TOOL_OPT_USE_SNAP]); tool_option_button[TOOL_OPT_USE_SNAP]->set_toggle_mode(true); tool_option_button[TOOL_OPT_USE_SNAP]->set_theme_type_variation("FlatButton"); - tool_option_button[TOOL_OPT_USE_SNAP]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_USE_SNAP)); + tool_option_button[TOOL_OPT_USE_SNAP]->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_USE_SNAP)); tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut(ED_SHORTCUT("spatial_editor/snap", TTR("Use Snap"), Key::Y)); tool_option_button[TOOL_OPT_USE_SNAP]->set_shortcut_context(this); @@ -8700,7 +8700,7 @@ Node3DEditor::Node3DEditor() { tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_toggle_mode(true); tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_theme_type_variation("FlatButton"); tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_disabled(true); - tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect("toggled", callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_OVERRIDE_CAMERA)); + tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->connect(SceneStringName(toggled), callable_mp(this, &Node3DEditor::_menu_item_toggled).bind(MENU_TOOL_OVERRIDE_CAMERA)); _update_camera_override_button(false); main_menu_hbox->add_child(memnew(VSeparator)); diff --git a/editor/plugins/particle_process_material_editor_plugin.cpp b/editor/plugins/particle_process_material_editor_plugin.cpp index 79c9c69584..67c9403aaf 100644 --- a/editor/plugins/particle_process_material_editor_plugin.cpp +++ b/editor/plugins/particle_process_material_editor_plugin.cpp @@ -438,7 +438,7 @@ ParticleProcessMaterialMinMaxPropertyEditor::ParticleProcessMaterialMinMaxProper toggle_mode_button->set_toggle_mode(true); toggle_mode_button->set_tooltip_text(TTR("Toggle between minimum/maximum and base value/spread modes.")); hb->add_child(toggle_mode_button); - toggle_mode_button->connect(SNAME("toggled"), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_toggle_mode)); + toggle_mode_button->connect(SceneStringName(toggled), callable_mp(this, &ParticleProcessMaterialMinMaxPropertyEditor::_toggle_mode)); set_bottom_editor(content_vb); } diff --git a/editor/plugins/physical_bone_3d_editor_plugin.cpp b/editor/plugins/physical_bone_3d_editor_plugin.cpp index d7e9701452..c858fa8606 100644 --- a/editor/plugins/physical_bone_3d_editor_plugin.cpp +++ b/editor/plugins/physical_bone_3d_editor_plugin.cpp @@ -62,7 +62,7 @@ PhysicalBone3DEditor::PhysicalBone3DEditor() { // when the editor theme updates. button_transform_joint->set_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("PhysicalBone3D"), EditorStringName(EditorIcons))); button_transform_joint->set_toggle_mode(true); - button_transform_joint->connect("toggled", callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint)); + button_transform_joint->connect(SceneStringName(toggled), callable_mp(this, &PhysicalBone3DEditor::_on_toggle_button_transform_joint)); hide(); } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 7c350f1e6d..496323aa2a 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -1468,7 +1468,7 @@ Polygon2DEditor::Polygon2DEditor() { b_snap_enable->set_toggle_mode(true); b_snap_enable->set_pressed(use_snap); b_snap_enable->set_tooltip_text(TTR("Enable Snap")); - b_snap_enable->connect("toggled", callable_mp(this, &Polygon2DEditor::_set_use_snap)); + b_snap_enable->connect(SceneStringName(toggled), callable_mp(this, &Polygon2DEditor::_set_use_snap)); b_snap_grid = memnew(Button); b_snap_grid->set_theme_type_variation("FlatButton"); @@ -1478,7 +1478,7 @@ Polygon2DEditor::Polygon2DEditor() { b_snap_grid->set_toggle_mode(true); b_snap_grid->set_pressed(snap_show_grid); b_snap_grid->set_tooltip_text(TTR("Show Grid")); - b_snap_grid->connect("toggled", callable_mp(this, &Polygon2DEditor::_set_show_grid)); + b_snap_grid->connect(SceneStringName(toggled), callable_mp(this, &Polygon2DEditor::_set_show_grid)); grid_settings = memnew(AcceptDialog); grid_settings->set_title(TTR("Configure Grid:")); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 7a052ebc19..a33fc47955 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -4063,7 +4063,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) { members_overview_alphabeta_sort_button->set_tooltip_text(TTR("Toggle alphabetical sorting of the method list.")); members_overview_alphabeta_sort_button->set_toggle_mode(true); members_overview_alphabeta_sort_button->set_pressed(EDITOR_GET("text_editor/script_list/sort_members_outline_alphabetically")); - members_overview_alphabeta_sort_button->connect("toggled", callable_mp(this, &ScriptEditor::_toggle_members_overview_alpha_sort)); + members_overview_alphabeta_sort_button->connect(SceneStringName(toggled), callable_mp(this, &ScriptEditor::_toggle_members_overview_alpha_sort)); buttons_hbox->add_child(members_overview_alphabeta_sort_button); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index eb39a27d02..34557b26b4 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -2373,6 +2373,7 @@ void ScriptTextEditor::_enable_code_editor() { ScriptTextEditor::ScriptTextEditor() { code_editor = memnew(CodeTextEditor); + code_editor->set_toggle_list_control(ScriptEditor::get_singleton()->get_left_list_split()); code_editor->add_theme_constant_override("separation", 2); code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); code_editor->set_code_complete_func(_code_complete_scripts, this); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 04a392768a..ea049756b7 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -149,7 +149,9 @@ void ShaderEditorPlugin::edit(Object *p_object) { } } es.shader_inc = Ref<ShaderInclude>(si); - es.shader_editor = memnew(TextShaderEditor); + TextShaderEditor *text_shader = memnew(TextShaderEditor); + text_shader->get_code_editor()->set_toggle_list_control(left_panel); + es.shader_editor = text_shader; es.shader_editor->edit_shader_include(si); shader_tabs->add_child(es.shader_editor); } else { @@ -166,7 +168,9 @@ void ShaderEditorPlugin::edit(Object *p_object) { if (vs.is_valid()) { es.shader_editor = memnew(VisualShaderEditor); } else { - es.shader_editor = memnew(TextShaderEditor); + TextShaderEditor *text_shader = memnew(TextShaderEditor); + text_shader->get_code_editor()->set_toggle_list_control(left_panel); + es.shader_editor = text_shader; } shader_tabs->add_child(es.shader_editor); es.shader_editor->edit_shader(es.shader); @@ -434,6 +438,10 @@ void ShaderEditorPlugin::_close_shader(int p_index) { edited_shaders.remove_at(p_index); _update_shader_list(); EditorUndoRedoManager::get_singleton()->clear_history(); // To prevent undo on deleted graphs. + + if (shader_tabs->get_tab_count() == 0) { + left_panel->show(); // Make sure the panel is visible, because it can't be toggled without open shaders. + } } void ShaderEditorPlugin::_close_builtin_shaders_from_scene(const String &p_scene) { @@ -768,10 +776,10 @@ ShaderEditorPlugin::ShaderEditorPlugin() { Ref<Shortcut> make_floating_shortcut = ED_SHORTCUT_AND_COMMAND("shader_editor/make_floating", TTR("Make Floating")); window_wrapper->set_wrapped_control(main_split, make_floating_shortcut); - VBoxContainer *vb = memnew(VBoxContainer); + left_panel = memnew(VBoxContainer); HBoxContainer *menu_hb = memnew(HBoxContainer); - vb->add_child(menu_hb); + left_panel->add_child(menu_hb); file_menu = memnew(MenuButton); file_menu->set_text(TTR("File")); file_menu->set_shortcut_context(main_split); @@ -803,14 +811,14 @@ ShaderEditorPlugin::ShaderEditorPlugin() { shader_list = memnew(ItemList); shader_list->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED); shader_list->set_v_size_flags(Control::SIZE_EXPAND_FILL); - vb->add_child(shader_list); + left_panel->add_child(shader_list); shader_list->connect(SceneStringName(item_selected), callable_mp(this, &ShaderEditorPlugin::_shader_selected)); shader_list->connect("item_clicked", callable_mp(this, &ShaderEditorPlugin::_shader_list_clicked)); shader_list->set_allow_rmb_select(true); SET_DRAG_FORWARDING_GCD(shader_list, ShaderEditorPlugin); - main_split->add_child(vb); - vb->set_custom_minimum_size(Size2(200, 300) * EDSCALE); + main_split->add_child(left_panel); + left_panel->set_custom_minimum_size(Size2(200, 300) * EDSCALE); shader_tabs = memnew(TabContainer); shader_tabs->set_tabs_visible(false); @@ -823,7 +831,7 @@ ShaderEditorPlugin::ShaderEditorPlugin() { button = EditorNode::get_bottom_panel()->add_item(TTR("Shader Editor"), window_wrapper, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_shader_editor_bottom_panel", TTR("Toggle Shader Editor Bottom Panel"), KeyModifierMask::ALT | Key::S)); shader_create_dialog = memnew(ShaderCreateDialog); - vb->add_child(shader_create_dialog); + main_split->add_child(shader_create_dialog); shader_create_dialog->connect("shader_created", callable_mp(this, &ShaderEditorPlugin::_shader_created)); shader_create_dialog->connect("shader_include_created", callable_mp(this, &ShaderEditorPlugin::_shader_include_created)); } diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 31be64a56c..43e6af79fa 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -40,6 +40,7 @@ class ShaderCreateDialog; class ShaderEditor; class TabContainer; class TextShaderEditor; +class VBoxContainer; class VisualShaderEditor; class WindowWrapper; @@ -82,6 +83,7 @@ class ShaderEditorPlugin : public EditorPlugin { }; HSplitContainer *main_split = nullptr; + VBoxContainer *left_panel = nullptr; ItemList *shader_list = nullptr; TabContainer *shader_tabs = nullptr; diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index b340dd976e..230d5809aa 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -747,7 +747,7 @@ void Skeleton3DEditor::create_editors() { edit_mode_button->set_toggle_mode(true); edit_mode_button->set_focus_mode(FOCUS_NONE); edit_mode_button->set_tooltip_text(TTR("Edit Mode\nShow buttons on joints.")); - edit_mode_button->connect("toggled", callable_mp(this, &Skeleton3DEditor::edit_mode_toggled)); + edit_mode_button->connect(SceneStringName(toggled), callable_mp(this, &Skeleton3DEditor::edit_mode_toggled)); edit_mode = false; diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp index 6ecbff3bb4..0b53c10fab 100644 --- a/editor/plugins/style_box_editor_plugin.cpp +++ b/editor/plugins/style_box_editor_plugin.cpp @@ -113,7 +113,7 @@ StyleBoxPreview::StyleBoxPreview() { // This theme variation works better than the normal theme because there's no focus highlight. grid_preview->set_theme_type_variation("PreviewLightButton"); grid_preview->set_toggle_mode(true); - grid_preview->connect("toggled", callable_mp(this, &StyleBoxPreview::_grid_preview_toggled)); + grid_preview->connect(SceneStringName(toggled), callable_mp(this, &StyleBoxPreview::_grid_preview_toggled)); grid_preview->set_pressed(grid_preview_enabled); add_child(grid_preview); } diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index cb1f6c1ec6..c1bcd43b2e 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -35,6 +35,7 @@ #include "editor/editor_node.h" #include "editor/editor_settings.h" #include "scene/gui/menu_button.h" +#include "scene/gui/split_container.h" void TextEditor::add_syntax_highlighter(Ref<EditorSyntaxHighlighter> p_highlighter) { ERR_FAIL_COND(p_highlighter.is_null()); @@ -606,6 +607,7 @@ TextEditor::TextEditor() { code_editor->set_anchors_and_offsets_preset(Control::PRESET_FULL_RECT); code_editor->set_v_size_flags(Control::SIZE_EXPAND_FILL); code_editor->show_toggle_scripts_button(); + code_editor->set_toggle_list_control(ScriptEditor::get_singleton()->get_left_list_split()); update_settings(); diff --git a/editor/plugins/text_shader_editor.cpp b/editor/plugins/text_shader_editor.cpp index 4d8f3298b6..0ff7aaa3fe 100644 --- a/editor/plugins/text_shader_editor.cpp +++ b/editor/plugins/text_shader_editor.cpp @@ -1256,4 +1256,5 @@ TextShaderEditor::TextShaderEditor() { add_child(disk_changed); _editor_settings_changed(); + code_editor->show_toggle_scripts_button(); // TODO: Disabled for now, because it doesn't work properly. } diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp index af52243c41..8dbf58e228 100644 --- a/editor/plugins/tiles/tile_data_editors.cpp +++ b/editor/plugins/tiles/tile_data_editors.cpp @@ -917,7 +917,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() { button_expand->set_toggle_mode(true); button_expand->set_pressed(false); button_expand->set_tooltip_text(TTR("Expand editor")); - button_expand->connect("toggled", callable_mp(this, &GenericTilePolygonEditor::_toggle_expand)); + button_expand->connect(SceneStringName(toggled), callable_mp(this, &GenericTilePolygonEditor::_toggle_expand)); toolbar->add_child(button_expand); toolbar->add_child(memnew(VSeparator)); diff --git a/editor/plugins/tiles/tile_map_layer_editor.cpp b/editor/plugins/tiles/tile_map_layer_editor.cpp index 63a54372b5..7e7d7e3291 100644 --- a/editor/plugins/tiles/tile_map_layer_editor.cpp +++ b/editor/plugins/tiles/tile_map_layer_editor.cpp @@ -2330,7 +2330,7 @@ TileMapLayerEditorTilesPlugin::TileMapLayerEditorTilesPlugin() { random_tile_toggle->set_theme_type_variation("FlatButton"); random_tile_toggle->set_toggle_mode(true); random_tile_toggle->set_tooltip_text(TTR("Place Random Tile")); - random_tile_toggle->connect("toggled", callable_mp(this, &TileMapLayerEditorTilesPlugin::_on_random_tile_checkbox_toggled)); + random_tile_toggle->connect(SceneStringName(toggled), callable_mp(this, &TileMapLayerEditorTilesPlugin::_on_random_tile_checkbox_toggled)); tools_settings->add_child(random_tile_toggle); // Random tile scattering. @@ -4486,7 +4486,7 @@ TileMapLayerEditor::TileMapLayerEditor() { toggle_highlight_selected_layer_button->set_theme_type_variation("FlatButton"); toggle_highlight_selected_layer_button->set_toggle_mode(true); toggle_highlight_selected_layer_button->set_pressed(true); - toggle_highlight_selected_layer_button->connect("toggled", callable_mp(this, &TileMapLayerEditor::_highlight_selected_layer_button_toggled)); + toggle_highlight_selected_layer_button->connect(SceneStringName(toggled), callable_mp(this, &TileMapLayerEditor::_highlight_selected_layer_button_toggled)); toggle_highlight_selected_layer_button->set_tooltip_text(TTR("Highlight Selected TileMap Layer")); tile_map_toolbar->add_child(toggle_highlight_selected_layer_button); @@ -4497,7 +4497,7 @@ TileMapLayerEditor::TileMapLayerEditor() { toggle_grid_button->set_theme_type_variation("FlatButton"); toggle_grid_button->set_toggle_mode(true); toggle_grid_button->set_tooltip_text(TTR("Toggle grid visibility.")); - toggle_grid_button->connect("toggled", callable_mp(this, &TileMapLayerEditor::_on_grid_toggled)); + toggle_grid_button->connect(SceneStringName(toggled), callable_mp(this, &TileMapLayerEditor::_on_grid_toggled)); tile_map_toolbar->add_child(toggle_grid_button); // Advanced settings menu button. diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp index 071be13692..1df84cb0a7 100644 --- a/editor/plugins/version_control_editor_plugin.cpp +++ b/editor/plugins/version_control_editor_plugin.cpp @@ -1006,7 +1006,7 @@ VersionControlEditorPlugin::VersionControlEditorPlugin() { toggle_vcs_choice = memnew(CheckButton); toggle_vcs_choice->set_h_size_flags(Control::SIZE_EXPAND_FILL); toggle_vcs_choice->set_pressed_no_signal(false); - toggle_vcs_choice->connect(SNAME("toggled"), callable_mp(this, &VersionControlEditorPlugin::_toggle_vcs_integration)); + toggle_vcs_choice->connect(SceneStringName(toggled), callable_mp(this, &VersionControlEditorPlugin::_toggle_vcs_integration)); toggle_vcs_hbc->add_child(toggle_vcs_choice); set_up_vbc->add_child(memnew(HSeparator)); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 0c541b6046..3059d10c4c 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -6382,7 +6382,7 @@ VisualShaderEditor::VisualShaderEditor() { custom_mode_box->set_text(TTR("Custom")); custom_mode_box->set_pressed(false); custom_mode_box->set_visible(false); - custom_mode_box->connect("toggled", callable_mp(this, &VisualShaderEditor::_custom_mode_toggled)); + custom_mode_box->connect(SceneStringName(toggled), callable_mp(this, &VisualShaderEditor::_custom_mode_toggled)); edit_type_standard = memnew(OptionButton); edit_type_standard->add_item(TTR("Vertex")); diff --git a/editor/project_manager/project_dialog.cpp b/editor/project_manager/project_dialog.cpp index 28d2362c9c..9b009c0a89 100644 --- a/editor/project_manager/project_dialog.cpp +++ b/editor/project_manager/project_dialog.cpp @@ -857,7 +857,7 @@ ProjectDialog::ProjectDialog() { create_dir->set_text(TTR("Create Folder")); create_dir->set_pressed(true); pphb_label->add_child(create_dir); - create_dir->connect("toggled", callable_mp(this, &ProjectDialog::_create_dir_toggled)); + create_dir->connect(SceneStringName(toggled), callable_mp(this, &ProjectDialog::_create_dir_toggled)); HBoxContainer *pphb = memnew(HBoxContainer); project_path_container->add_child(pphb); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 373895b653..489fbb037f 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -652,7 +652,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { advanced = memnew(CheckButton); advanced->set_text(TTR("Advanced Settings")); - advanced->connect("toggled", callable_mp(this, &ProjectSettingsEditor::_advanced_toggled)); + advanced->connect(SceneStringName(toggled), callable_mp(this, &ProjectSettingsEditor::_advanced_toggled)); search_bar->add_child(advanced); custom_properties = memnew(HBoxContainer); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 71d2ccf124..2ef7de1538 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -304,7 +304,7 @@ RenameDialog::RenameDialog(SceneTreeEditor *p_scene_tree_editor) { // ---- Connections - cbut_collapse_features->connect("toggled", callable_mp(this, &RenameDialog::_features_toggled)); + cbut_collapse_features->connect(SceneStringName(toggled), callable_mp(this, &RenameDialog::_features_toggled)); // Substitute Buttons diff --git a/editor/run_instances_dialog.cpp b/editor/run_instances_dialog.cpp index d617c899ad..bb32748653 100644 --- a/editor/run_instances_dialog.cpp +++ b/editor/run_instances_dialog.cpp @@ -304,7 +304,7 @@ RunInstancesDialog::RunInstancesDialog() { args_gc->add_child(instance_count); instance_count->connect(SceneStringName(value_changed), callable_mp(this, &RunInstancesDialog::_start_instance_timer).unbind(1)); instance_count->connect(SceneStringName(value_changed), callable_mp(this, &RunInstancesDialog::_refresh_argument_count).unbind(1)); - enable_multiple_instances_checkbox->connect("toggled", callable_mp(instance_count, &SpinBox::set_editable)); + enable_multiple_instances_checkbox->connect(SceneStringName(toggled), callable_mp(instance_count, &SpinBox::set_editable)); instance_count->set_editable(enable_multiple_instances_checkbox->is_pressed()); main_args_edit = memnew(LineEdit); diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index fd9d5bc127..846e8867a1 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -629,7 +629,7 @@ ShaderCreateDialog::ShaderCreateDialog() { internal = memnew(CheckBox); internal->set_text(TTR("On")); - internal->connect("toggled", callable_mp(this, &ShaderCreateDialog::_built_in_toggled)); + internal->connect(SceneStringName(toggled), callable_mp(this, &ShaderCreateDialog::_built_in_toggled)); gc->add_child(memnew(Label(TTR("Built-in Shader:")))); gc->add_child(internal); diff --git a/misc/extension_api_validation/4.3-stable.expected b/misc/extension_api_validation/4.3-stable.expected index 80735f28e7..39dd064012 100644 --- a/misc/extension_api_validation/4.3-stable.expected +++ b/misc/extension_api_validation/4.3-stable.expected @@ -48,3 +48,11 @@ GH-93605 Validate extension JSON: JSON file: Field was added in a way that breaks compatibility 'classes/Semaphore/methods/post': arguments Optional arguments added. Compatibility methods registered. + + +GH-95212 +-------- +Validate extension JSON: Error: Field 'classes/RegEx/methods/compile/arguments': size changed value in new API, from 1 to 2. +Validate extension JSON: Error: Field 'classes/RegEx/methods/create_from_string/arguments': size changed value in new API, from 1 to 2. + +Add optional argument to control error printing on compilation fail. Compatibility methods registered. diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml index ab74fce3a9..e12dc43b6f 100644 --- a/modules/regex/doc_classes/RegEx.xml +++ b/modules/regex/doc_classes/RegEx.xml @@ -58,15 +58,17 @@ <method name="compile"> <return type="int" enum="Error" /> <param index="0" name="pattern" type="String" /> + <param index="1" name="show_error" type="bool" default="true" /> <description> - Compiles and assign the search pattern to use. Returns [constant OK] if the compilation is successful. If an error is encountered, details are printed to standard output and an error is returned. + Compiles and assign the search pattern to use. Returns [constant OK] if the compilation is successful. If compilation fails, returns [constant FAILED] and when [param show_error] is [code]true[/code], details are printed to standard output. </description> </method> <method name="create_from_string" qualifiers="static"> <return type="RegEx" /> <param index="0" name="pattern" type="String" /> + <param index="1" name="show_error" type="bool" default="true" /> <description> - Creates and compiles a new [RegEx] object. + Creates and compiles a new [RegEx] object. See also [method compile]. </description> </method> <method name="get_group_count" qualifiers="const"> diff --git a/modules/regex/regex.compat.inc b/modules/regex/regex.compat.inc new file mode 100644 index 0000000000..0c380655a4 --- /dev/null +++ b/modules/regex/regex.compat.inc @@ -0,0 +1,46 @@ +/**************************************************************************/ +/* regex.compat.inc */ +/**************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/**************************************************************************/ +/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ +/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/**************************************************************************/ + +#ifndef DISABLE_DEPRECATED + +Ref<RegEx> RegEx::_create_from_string_bind_compat_95212(const String &p_pattern) { + return create_from_string(p_pattern, true); +} + +Error RegEx::_compile_bind_compat_95212(const String &p_pattern) { + return compile(p_pattern, true); +} + +void RegEx::_bind_compatibility_methods() { + ClassDB::bind_compatibility_static_method("RegEx", D_METHOD("create_from_string", "pattern"), &RegEx::_create_from_string_bind_compat_95212); + ClassDB::bind_compatibility_method(D_METHOD("compile", "pattern"), &RegEx::_compile_bind_compat_95212); +} + +#endif diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 9f34a6ca6a..85c0b9ecad 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -29,6 +29,7 @@ /**************************************************************************/ #include "regex.h" +#include "regex.compat.inc" #include "core/os/memory.h" @@ -161,10 +162,10 @@ void RegEx::_pattern_info(uint32_t what, void *where) const { pcre2_pattern_info_32((pcre2_code_32 *)code, what, where); } -Ref<RegEx> RegEx::create_from_string(const String &p_pattern) { +Ref<RegEx> RegEx::create_from_string(const String &p_pattern, bool p_show_error) { Ref<RegEx> ret; ret.instantiate(); - ret->compile(p_pattern); + ret->compile(p_pattern, p_show_error); return ret; } @@ -175,7 +176,7 @@ void RegEx::clear() { } } -Error RegEx::compile(const String &p_pattern) { +Error RegEx::compile(const String &p_pattern, bool p_show_error) { pattern = p_pattern; clear(); @@ -192,10 +193,12 @@ Error RegEx::compile(const String &p_pattern) { pcre2_compile_context_free_32(cctx); if (!code) { - PCRE2_UCHAR32 buf[256]; - pcre2_get_error_message_32(err, buf, 256); - String message = String::num(offset) + ": " + String((const char32_t *)buf); - ERR_PRINT(message.utf8()); + if (p_show_error) { + PCRE2_UCHAR32 buf[256]; + pcre2_get_error_message_32(err, buf, 256); + String message = String::num(offset) + ": " + String((const char32_t *)buf); + ERR_PRINT(message.utf8()); + } return FAILED; } return OK; @@ -395,10 +398,10 @@ RegEx::~RegEx() { } void RegEx::_bind_methods() { - ClassDB::bind_static_method("RegEx", D_METHOD("create_from_string", "pattern"), &RegEx::create_from_string); + ClassDB::bind_static_method("RegEx", D_METHOD("create_from_string", "pattern", "show_error"), &RegEx::create_from_string, DEFVAL(true)); ClassDB::bind_method(D_METHOD("clear"), &RegEx::clear); - ClassDB::bind_method(D_METHOD("compile", "pattern"), &RegEx::compile); + ClassDB::bind_method(D_METHOD("compile", "pattern", "show_error"), &RegEx::compile, DEFVAL(true)); ClassDB::bind_method(D_METHOD("search", "subject", "offset", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("search_all", "subject", "offset", "end"), &RegEx::search_all, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("sub", "subject", "replacement", "all", "offset", "end"), &RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1)); diff --git a/modules/regex/regex.h b/modules/regex/regex.h index 13476d69de..cb8b0459ad 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -81,11 +81,17 @@ class RegEx : public RefCounted { protected: static void _bind_methods(); +#ifndef DISABLE_DEPRECATED + static Ref<RegEx> _create_from_string_bind_compat_95212(const String &p_pattern); + Error _compile_bind_compat_95212(const String &p_pattern); + static void _bind_compatibility_methods(); +#endif + public: - static Ref<RegEx> create_from_string(const String &p_pattern); + static Ref<RegEx> create_from_string(const String &p_pattern, bool p_show_error = true); void clear(); - Error compile(const String &p_pattern); + Error compile(const String &p_pattern, bool p_show_error = true); Ref<RegExMatch> search(const String &p_subject, int p_offset = 0, int p_end = -1) const; TypedArray<RegExMatch> search_all(const String &p_subject, int p_offset = 0, int p_end = -1) const; diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 01e3cce78b..ed7e0de0e2 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -140,7 +140,7 @@ void BaseButton::_pressed() { void BaseButton::_toggled(bool p_pressed) { GDVIRTUAL_CALL(_toggled, p_pressed); toggled(p_pressed); - emit_signal(SNAME("toggled"), p_pressed); + emit_signal(SceneStringName(toggled), p_pressed); } void BaseButton::on_action_event(Ref<InputEvent> p_event) { diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 8a3edc25b9..c92dcbc153 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -783,7 +783,7 @@ void ColorPicker::_add_recent_preset_button(int p_size, const Color &p_color) { recent_preset_hbc->add_child(btn_preset_new); recent_preset_hbc->move_child(btn_preset_new, 0); btn_preset_new->set_pressed(true); - btn_preset_new->connect("toggled", callable_mp(this, &ColorPicker::_recent_preset_pressed).bind(btn_preset_new)); + btn_preset_new->connect(SceneStringName(toggled), callable_mp(this, &ColorPicker::_recent_preset_pressed).bind(btn_preset_new)); } void ColorPicker::_show_hide_preset(const bool &p_is_btn_pressed, Button *p_btn_preset, Container *p_preset_container) { @@ -2003,7 +2003,7 @@ ColorPicker::ColorPicker() { btn_preset->set_toggle_mode(true); btn_preset->set_focus_mode(FOCUS_NONE); btn_preset->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT); - btn_preset->connect("toggled", callable_mp(this, &ColorPicker::_show_hide_preset).bind(btn_preset, preset_container)); + btn_preset->connect(SceneStringName(toggled), callable_mp(this, &ColorPicker::_show_hide_preset).bind(btn_preset, preset_container)); real_vbox->add_child(btn_preset); real_vbox->add_child(preset_container); @@ -2020,7 +2020,7 @@ ColorPicker::ColorPicker() { btn_recent_preset->set_toggle_mode(true); btn_recent_preset->set_focus_mode(FOCUS_NONE); btn_recent_preset->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT); - btn_recent_preset->connect("toggled", callable_mp(this, &ColorPicker::_show_hide_preset).bind(btn_recent_preset, recent_preset_hbc)); + btn_recent_preset->connect(SceneStringName(toggled), callable_mp(this, &ColorPicker::_show_hide_preset).bind(btn_recent_preset, recent_preset_hbc)); real_vbox->add_child(btn_recent_preset); real_vbox->add_child(recent_preset_hbc); diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 8047369ab1..1a1aa5ccb0 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -1143,7 +1143,7 @@ void FileDialog::_update_option_controls() { CheckBox *cb = memnew(CheckBox); cb->set_pressed(opt.default_idx); grid_options->add_child(cb); - cb->connect("toggled", callable_mp(this, &FileDialog::_option_changed_checkbox_toggled).bind(opt.name)); + cb->connect(SceneStringName(toggled), callable_mp(this, &FileDialog::_option_changed_checkbox_toggled).bind(opt.name)); selected_options[opt.name] = (bool)opt.default_idx; } else { OptionButton *ob = memnew(OptionButton); @@ -1441,7 +1441,7 @@ FileDialog::FileDialog() { show_hidden->set_toggle_mode(true); show_hidden->set_pressed(is_showing_hidden_files()); show_hidden->set_tooltip_text(ETR("Toggle the visibility of hidden files.")); - show_hidden->connect("toggled", callable_mp(this, &FileDialog::set_show_hidden_files)); + show_hidden->connect(SceneStringName(toggled), callable_mp(this, &FileDialog::set_show_hidden_files)); hbc->add_child(show_hidden); shortcuts_container = memnew(HBoxContainer); diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp index 3264733548..c8b022d622 100644 --- a/scene/gui/menu_bar.cpp +++ b/scene/gui/menu_bar.cpp @@ -680,10 +680,7 @@ void MenuBar::_bind_methods() { ClassDB::bind_method(D_METHOD("set_menu_hidden", "menu", "hidden"), &MenuBar::set_menu_hidden); ClassDB::bind_method(D_METHOD("is_menu_hidden", "menu"), &MenuBar::is_menu_hidden); - // TODO: Properly handle popups when advanced GUI is disabled. -#ifndef ADVANCED_GUI_DISABLED ClassDB::bind_method(D_METHOD("get_menu_popup", "menu"), &MenuBar::get_menu_popup); -#endif // ADVANCED_GUI_DISABLED ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flat"), "set_flat", "is_flat"); ADD_PROPERTY(PropertyInfo(Variant::INT, "start_index"), "set_start_index", "get_start_index"); diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index 8c5bb1b33d..1069a752c4 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -173,10 +173,7 @@ bool MenuButton::_get(const StringName &p_name, Variant &r_ret) const { } void MenuButton::_bind_methods() { - // TODO: Properly handle popups when advanced GUI is disabled. -#ifndef ADVANCED_GUI_DISABLED ClassDB::bind_method(D_METHOD("get_popup"), &MenuButton::get_popup); -#endif // ADVANCED_GUI_DISABLED ClassDB::bind_method(D_METHOD("show_popup"), &MenuButton::show_popup); ClassDB::bind_method(D_METHOD("set_switch_on_hover", "enable"), &MenuButton::set_switch_on_hover); ClassDB::bind_method(D_METHOD("is_switch_on_hover"), &MenuButton::is_switch_on_hover); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index aa8ff75c6a..76678e609a 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -402,8 +402,6 @@ void register_scene_types() { GDREGISTER_CLASS(VSlider); GDREGISTER_CLASS(Popup); GDREGISTER_CLASS(PopupPanel); - GDREGISTER_CLASS(MenuBar); - GDREGISTER_CLASS(MenuButton); GDREGISTER_CLASS(CheckBox); GDREGISTER_CLASS(CheckButton); GDREGISTER_CLASS(LinkButton); @@ -458,6 +456,8 @@ void register_scene_types() { GDREGISTER_CLASS(CodeHighlighter); GDREGISTER_ABSTRACT_CLASS(TreeItem); + GDREGISTER_CLASS(MenuBar); + GDREGISTER_CLASS(MenuButton); GDREGISTER_CLASS(OptionButton); GDREGISTER_CLASS(SpinBox); GDREGISTER_CLASS(ColorPicker); diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index 40f3ddf048..f8a0336b37 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -132,6 +132,7 @@ SceneStringNames::SceneStringNames() { pressed = StaticCString::create("pressed"); id_pressed = StaticCString::create("id_pressed"); + toggled = StaticCString::create("toggled"); panel = StaticCString::create("panel"); diff --git a/scene/scene_string_names.h b/scene/scene_string_names.h index 7893d213e4..381a161ad5 100644 --- a/scene/scene_string_names.h +++ b/scene/scene_string_names.h @@ -145,6 +145,7 @@ public: StringName pressed; StringName id_pressed; + StringName toggled; StringName panel; |