summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-05-16 10:53:55 +0200
committerGitHub <noreply@github.com>2018-05-16 10:53:55 +0200
commit98e5a3ea426f12b4ae439f67d29a5c6cfc5f39d4 (patch)
tree2e4f461bbbf0c8d089cba375ade4e1c67428df79 /editor
parent17e84568a45df3b81c3a40dc8eab8dbc1f95329a (diff)
parent68b9fd79e475b14ea109b6b973944cc4def3f57d (diff)
Merge pull request #18442 from StraToN/add-button-sort-methods-overview
Add a ToggleButton for alphabetic sorting in methods overview
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/plugins/script_editor_plugin.cpp38
-rw-r--r--editor/plugins/script_editor_plugin.h4
3 files changed, 41 insertions, 2 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 68705fa29d..fe0392334c 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -383,6 +383,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/files/trim_trailing_whitespace_on_save", false);
_initial_set("text_editor/completion/idle_parse_delay", 2);
_initial_set("text_editor/tools/create_signal_callbacks", true);
+ _initial_set("text_editor/tools/sort_members_outline_alphabetically", false);
_initial_set("text_editor/files/autosave_interval_secs", 0);
_initial_set("text_editor/cursor/block_caret", false);
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index fa674e1e34..ac250f085d 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1182,6 +1182,7 @@ void ScriptEditor::_notification(int p_what) {
script_forward->set_icon(get_icon("Forward", "EditorIcons"));
script_back->set_icon(get_icon("Back", "EditorIcons"));
+ members_overview_alphabeta_sort_button->set_icon(get_icon("Sort", "EditorIcons"));
} break;
case NOTIFICATION_READY: {
@@ -1408,12 +1409,19 @@ void ScriptEditor::_update_members_overview_visibility() {
}
if (members_overview_enabled && se->show_members_overview()) {
+ members_overview_buttons_hbox->set_visible(true);
members_overview->set_visible(true);
} else {
+ members_overview_buttons_hbox->set_visible(false);
members_overview->set_visible(false);
}
}
+void ScriptEditor::_toggle_members_overview_alpha_sort(bool p_alphabetic_sort) {
+ EditorSettings::get_singleton()->set("text_editor/tools/sort_members_outline_alphabetically", p_alphabetic_sort);
+ _update_members_overview();
+}
+
void ScriptEditor::_update_members_overview() {
members_overview->clear();
@@ -1423,6 +1431,10 @@ void ScriptEditor::_update_members_overview() {
}
Vector<String> functions = se->get_functions();
+ if (EditorSettings::get_singleton()->get("text_editor/tools/sort_members_outline_alphabetically")) {
+ functions.sort();
+ }
+
for (int i = 0; i < functions.size(); i++) {
members_overview->add_item(functions[i].get_slice(":", 0));
members_overview->set_item_metadata(i, functions[i].get_slice(":", 1).to_int() - 1);
@@ -1445,6 +1457,7 @@ void ScriptEditor::_update_help_overview_visibility() {
}
if (help_overview_enabled) {
+ members_overview_buttons_hbox->set_visible(false);
help_overview->set_visible(true);
} else {
help_overview->set_visible(false);
@@ -2596,6 +2609,8 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
ClassDB::bind_method("_script_list_gui_input", &ScriptEditor::_script_list_gui_input);
+ ClassDB::bind_method("_toggle_members_overview_alpha_sort", &ScriptEditor::_toggle_members_overview_alpha_sort);
+ ClassDB::bind_method("_update_members_overview", &ScriptEditor::_update_members_overview);
ClassDB::bind_method("_script_changed", &ScriptEditor::_script_changed);
ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts);
ClassDB::bind_method("_on_find_in_files_requested", &ScriptEditor::_on_find_in_files_requested);
@@ -2656,14 +2671,33 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
add_child(context_menu);
context_menu->connect("id_pressed", this, "_menu_option");
+ members_overview_vbox = memnew(VBoxContainer);
+ members_overview_vbox->set_custom_minimum_size(Size2(0, 90));
+ members_overview_vbox->set_v_size_flags(SIZE_EXPAND_FILL);
+
+ list_split->add_child(members_overview_vbox);
+ members_overview_buttons_hbox = memnew(HBoxContainer);
+ members_overview_vbox->add_child(members_overview_buttons_hbox);
+
+ members_overview_alphabeta_sort_button = memnew(ToolButton);
+ members_overview_alphabeta_sort_button->set_tooltip(TTR("Sort alphabetically"));
+ members_overview_alphabeta_sort_button->set_toggle_mode(true);
+ members_overview_alphabeta_sort_button->set_pressed(EditorSettings::get_singleton()->get("text_editor/tools/sort_members_outline_alphabetically"));
+ members_overview_alphabeta_sort_button->connect("toggled", this, "_toggle_members_overview_alpha_sort");
+
+ members_overview_buttons_hbox->add_child(members_overview_alphabeta_sort_button);
+
members_overview = memnew(ItemList);
- list_split->add_child(members_overview);
+ members_overview_vbox->add_child(members_overview);
+
members_overview->set_allow_reselect(true);
members_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing
members_overview->set_v_size_flags(SIZE_EXPAND_FILL);
+ members_overview->set_allow_rmb_select(true);
+ members_overview->set_drag_forwarding(this);
help_overview = memnew(ItemList);
- list_split->add_child(help_overview);
+ members_overview_vbox->add_child(help_overview);
help_overview->set_allow_reselect(true);
help_overview->set_custom_minimum_size(Size2(0, 90)); //need to give a bit of limit to avoid it from disappearing
help_overview->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 9f37b18d7d..a2ff47cd99 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -199,6 +199,9 @@ class ScriptEditor : public PanelContainer {
ItemList *script_list;
HSplitContainer *script_split;
ItemList *members_overview;
+ VBoxContainer *members_overview_vbox;
+ HBoxContainer *members_overview_buttons_hbox;
+ ToolButton *members_overview_alphabeta_sort_button;
bool members_overview_enabled;
ItemList *help_overview;
bool help_overview_enabled;
@@ -318,6 +321,7 @@ class ScriptEditor : public PanelContainer {
void _update_members_overview_visibility();
void _update_members_overview();
+ void _toggle_members_overview_alpha_sort(bool p_alphabetic_sort);
void _update_script_names();
bool _sort_list_on_update;