| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*  editor_help_search.cpp                                               */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | /*                       This file is part of:                           */ | 
					
						
							|  |  |  | /*                           GODOT ENGINE                                */ | 
					
						
							|  |  |  | /*                      https://godotengine.org                          */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							| 
									
										
										
										
											2022-01-03 21:27:34 +01:00
										 |  |  | /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur.                 */ | 
					
						
							|  |  |  | /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md).   */ | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | /*                                                                       */ | 
					
						
							|  |  |  | /* 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.                */ | 
					
						
							|  |  |  | /*************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "editor_help_search.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "core/os/keyboard.h"
 | 
					
						
							| 
									
										
										
										
											2022-02-12 02:46:22 +01:00
										 |  |  | #include "editor/editor_feature_profile.h"
 | 
					
						
							|  |  |  | #include "editor/editor_node.h"
 | 
					
						
							|  |  |  | #include "editor/editor_scale.h"
 | 
					
						
							| 
									
										
										
										
											2022-07-31 21:14:15 +03:00
										 |  |  | #include "editor/editor_settings.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_update_icons() { | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 	search_box->set_right_icon(results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	search_box->set_clear_button_enabled(true); | 
					
						
							| 
									
										
										
										
											2022-02-08 10:14:58 +01:00
										 |  |  | 	search_box->add_theme_icon_override("right_icon", results_tree->get_theme_icon(SNAME("Search"), SNAME("EditorIcons"))); | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 	case_sensitive_button->set_icon(results_tree->get_theme_icon(SNAME("MatchCase"), SNAME("EditorIcons"))); | 
					
						
							|  |  |  | 	hierarchy_button->set_icon(results_tree->get_theme_icon(SNAME("ClassList"), SNAME("EditorIcons"))); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (is_visible()) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		_update_results(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_update_results() { | 
					
						
							|  |  |  | 	String term = search_box->get_text(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int search_flags = filter_combo->get_selected_id(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (case_sensitive_button->is_pressed()) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		search_flags |= SEARCH_CASE_SENSITIVE; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	if (hierarchy_button->is_pressed()) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		search_flags |= SEARCH_SHOW_HIERARCHY; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 	search = Ref<Runner>(memnew(Runner(results_tree, results_tree, term, search_flags))); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	set_process(true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-22 21:20:57 -02:00
										 |  |  | void EditorHelpSearch::_search_box_gui_input(const Ref<InputEvent> &p_event) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	// Redirect up and down navigational key events to the results list.
 | 
					
						
							| 
									
										
										
										
											2018-11-22 21:20:57 -02:00
										 |  |  | 	Ref<InputEventKey> key = p_event; | 
					
						
							|  |  |  | 	if (key.is_valid()) { | 
					
						
							| 
									
										
										
										
											2018-04-05 20:59:35 +03:00
										 |  |  | 		switch (key->get_keycode()) { | 
					
						
							| 
									
										
										
										
											2021-08-13 16:31:57 -05:00
										 |  |  | 			case Key::UP: | 
					
						
							|  |  |  | 			case Key::DOWN: | 
					
						
							|  |  |  | 			case Key::PAGEUP: | 
					
						
							|  |  |  | 			case Key::PAGEDOWN: { | 
					
						
							| 
									
										
										
										
											2021-08-22 12:37:22 -03:00
										 |  |  | 				results_tree->gui_input(key); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 				search_box->accept_event(); | 
					
						
							|  |  |  | 			} break; | 
					
						
							| 
									
										
										
										
											2021-06-20 13:12:33 -04:00
										 |  |  | 			default: | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_search_box_text_changed(const String &p_text) { | 
					
						
							|  |  |  | 	_update_results(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_filter_combo_item_selected(int p_option) { | 
					
						
							|  |  |  | 	_update_results(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_confirmed() { | 
					
						
							| 
									
										
										
										
											2018-11-22 15:11:09 -02:00
										 |  |  | 	TreeItem *item = results_tree->get_selected(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (!item) { | 
					
						
							| 
									
										
										
										
											2018-11-22 15:11:09 -02:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-11-22 15:11:09 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	// Activate the script editor and emit the signal with the documentation link to display.
 | 
					
						
							|  |  |  | 	EditorNode::get_singleton()->set_visible_editor(EditorNode::EDITOR_SCRIPT); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 	emit_signal(SNAME("go_to_help"), item->get_metadata(0)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	hide(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_notification(int p_what) { | 
					
						
							|  |  |  | 	switch (p_what) { | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 		case NOTIFICATION_VISIBILITY_CHANGED: { | 
					
						
							|  |  |  | 			if (!is_visible()) { | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 				results_tree->call_deferred(SNAME("clear")); // Wait for the Tree's mouse event propagation.
 | 
					
						
							| 
									
										
										
										
											2020-12-14 18:37:30 +00:00
										 |  |  | 				get_ok_button()->set_disabled(true); | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 				EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "search_help", Rect2(get_position(), get_size())); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2022-02-16 00:52:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { | 
					
						
							|  |  |  | 			_update_icons(); | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2022-02-16 00:52:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		case NOTIFICATION_ENTER_TREE: { | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 			connect("confirmed", callable_mp(this, &EditorHelpSearch::_confirmed)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 			_update_icons(); | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		case NOTIFICATION_PROCESS: { | 
					
						
							|  |  |  | 			// Update background search.
 | 
					
						
							|  |  |  | 			if (search.is_valid()) { | 
					
						
							|  |  |  | 				if (search->work()) { | 
					
						
							|  |  |  | 					// Search done.
 | 
					
						
							| 
									
										
										
										
											2018-11-26 13:38:39 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-19 18:49:21 -03:00
										 |  |  | 					// Only point to the match if it's a new search, and not just reopening a old one.
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					if (!old_search) { | 
					
						
							| 
									
										
										
										
											2018-11-26 13:38:39 -02:00
										 |  |  | 						results_tree->ensure_cursor_is_visible(); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					} else { | 
					
						
							| 
									
										
										
										
											2018-11-26 13:38:39 -02:00
										 |  |  | 						old_search = false; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2018-11-26 13:38:39 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-14 18:37:30 +00:00
										 |  |  | 					get_ok_button()->set_disabled(!results_tree->get_selected()); | 
					
						
							| 
									
										
										
										
											2018-11-26 13:38:39 -02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 					search = Ref<Runner>(); | 
					
						
							|  |  |  | 					set_process(false); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				set_process(false); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::_bind_methods() { | 
					
						
							|  |  |  | 	ADD_SIGNAL(MethodInfo("go_to_help")); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::popup_dialog() { | 
					
						
							|  |  |  | 	popup_dialog(search_box->get_text()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::popup_dialog(const String &p_term) { | 
					
						
							|  |  |  | 	// Restore valid window bounds or pop up at default size.
 | 
					
						
							| 
									
										
										
										
											2018-12-04 13:52:56 -02:00
										 |  |  | 	Rect2 saved_size = EditorSettings::get_singleton()->get_project_metadata("dialog_bounds", "search_help", Rect2()); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (saved_size != Rect2()) { | 
					
						
							| 
									
										
										
										
											2018-12-04 13:52:56 -02:00
										 |  |  | 		popup(saved_size); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		popup_centered_ratio(0.5F); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-09 03:42:46 -06:00
										 |  |  | 	if (p_term.is_empty()) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		search_box->clear(); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (old_term == p_term) { | 
					
						
							| 
									
										
										
										
											2019-11-25 16:23:35 +01:00
										 |  |  | 			old_search = true; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2019-11-25 16:23:35 +01:00
										 |  |  | 			old_term = p_term; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-11-25 16:23:35 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		search_box->set_text(p_term); | 
					
						
							|  |  |  | 		search_box->select_all(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	search_box->grab_focus(); | 
					
						
							|  |  |  | 	_update_results(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | EditorHelpSearch::EditorHelpSearch() { | 
					
						
							|  |  |  | 	set_hide_on_ok(false); | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	set_title(TTR("Search Help")); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-14 18:37:30 +00:00
										 |  |  | 	get_ok_button()->set_disabled(true); | 
					
						
							| 
									
										
										
										
											2022-07-07 19:31:19 -05:00
										 |  |  | 	set_ok_button_text(TTR("Open")); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Split search and results area.
 | 
					
						
							|  |  |  | 	VBoxContainer *vbox = memnew(VBoxContainer); | 
					
						
							|  |  |  | 	add_child(vbox); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Create the search box and filter controls (at the top).
 | 
					
						
							|  |  |  | 	HBoxContainer *hbox = memnew(HBoxContainer); | 
					
						
							|  |  |  | 	vbox->add_child(hbox); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	search_box = memnew(LineEdit); | 
					
						
							| 
									
										
										
										
											2019-12-28 10:33:01 +08:00
										 |  |  | 	search_box->set_custom_minimum_size(Size2(200, 0) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 	search_box->set_h_size_flags(Control::SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 	search_box->connect("gui_input", callable_mp(this, &EditorHelpSearch::_search_box_gui_input)); | 
					
						
							|  |  |  | 	search_box->connect("text_changed", callable_mp(this, &EditorHelpSearch::_search_box_text_changed)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	register_text_enter(search_box); | 
					
						
							|  |  |  | 	hbox->add_child(search_box); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 	case_sensitive_button = memnew(Button); | 
					
						
							|  |  |  | 	case_sensitive_button->set_flat(true); | 
					
						
							| 
									
										
										
										
											2022-08-25 12:42:17 +02:00
										 |  |  | 	case_sensitive_button->set_tooltip_text(TTR("Case Sensitive")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 	case_sensitive_button->connect("pressed", callable_mp(this, &EditorHelpSearch::_update_results)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	case_sensitive_button->set_toggle_mode(true); | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 	case_sensitive_button->set_focus_mode(Control::FOCUS_NONE); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	hbox->add_child(case_sensitive_button); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-19 20:49:04 +02:00
										 |  |  | 	hierarchy_button = memnew(Button); | 
					
						
							|  |  |  | 	hierarchy_button->set_flat(true); | 
					
						
							| 
									
										
										
										
											2022-08-25 12:42:17 +02:00
										 |  |  | 	hierarchy_button->set_tooltip_text(TTR("Show Hierarchy")); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 	hierarchy_button->connect("pressed", callable_mp(this, &EditorHelpSearch::_update_results)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	hierarchy_button->set_toggle_mode(true); | 
					
						
							|  |  |  | 	hierarchy_button->set_pressed(true); | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 	hierarchy_button->set_focus_mode(Control::FOCUS_NONE); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	hbox->add_child(hierarchy_button); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	filter_combo = memnew(OptionButton); | 
					
						
							| 
									
										
										
										
											2019-12-28 10:33:01 +08:00
										 |  |  | 	filter_combo->set_custom_minimum_size(Size2(200, 0) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	filter_combo->set_stretch_ratio(0); // Fixed width.
 | 
					
						
							|  |  |  | 	filter_combo->add_item(TTR("Display All"), SEARCH_ALL); | 
					
						
							|  |  |  | 	filter_combo->add_separator(); | 
					
						
							|  |  |  | 	filter_combo->add_item(TTR("Classes Only"), SEARCH_CLASSES); | 
					
						
							| 
									
										
										
										
											2021-09-20 21:49:02 -05:00
										 |  |  | 	filter_combo->add_item(TTR("Constructors Only"), SEARCH_CONSTRUCTORS); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	filter_combo->add_item(TTR("Methods Only"), SEARCH_METHODS); | 
					
						
							| 
									
										
										
										
											2021-09-20 21:49:02 -05:00
										 |  |  | 	filter_combo->add_item(TTR("Operators Only"), SEARCH_OPERATORS); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	filter_combo->add_item(TTR("Signals Only"), SEARCH_SIGNALS); | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 	filter_combo->add_item(TTR("Annotations Only"), SEARCH_ANNOTATIONS); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	filter_combo->add_item(TTR("Constants Only"), SEARCH_CONSTANTS); | 
					
						
							|  |  |  | 	filter_combo->add_item(TTR("Properties Only"), SEARCH_PROPERTIES); | 
					
						
							|  |  |  | 	filter_combo->add_item(TTR("Theme Properties Only"), SEARCH_THEME_ITEMS); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 	filter_combo->connect("item_selected", callable_mp(this, &EditorHelpSearch::_filter_combo_item_selected)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	hbox->add_child(filter_combo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Create the results tree.
 | 
					
						
							|  |  |  | 	results_tree = memnew(Tree); | 
					
						
							| 
									
										
										
										
											2020-03-06 14:00:16 -03:00
										 |  |  | 	results_tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	results_tree->set_columns(2); | 
					
						
							|  |  |  | 	results_tree->set_column_title(0, TTR("Name")); | 
					
						
							| 
									
										
										
										
											2021-07-04 00:13:28 -03:00
										 |  |  | 	results_tree->set_column_clip_content(0, true); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	results_tree->set_column_title(1, TTR("Member Type")); | 
					
						
							|  |  |  | 	results_tree->set_column_expand(1, false); | 
					
						
							| 
									
										
										
										
											2021-06-28 15:40:56 +02:00
										 |  |  | 	results_tree->set_column_custom_minimum_width(1, 150 * EDSCALE); | 
					
						
							| 
									
										
										
										
											2021-07-04 00:13:28 -03:00
										 |  |  | 	results_tree->set_column_clip_content(1, true); | 
					
						
							| 
									
										
										
										
											2019-12-28 10:33:01 +08:00
										 |  |  | 	results_tree->set_custom_minimum_size(Size2(0, 100) * EDSCALE); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	results_tree->set_hide_root(true); | 
					
						
							|  |  |  | 	results_tree->set_select_mode(Tree::SELECT_ROW); | 
					
						
							| 
									
										
										
										
											2020-02-21 18:28:45 +01:00
										 |  |  | 	results_tree->connect("item_activated", callable_mp(this, &EditorHelpSearch::_confirmed)); | 
					
						
							| 
									
										
										
										
											2022-07-28 22:56:41 +02:00
										 |  |  | 	results_tree->connect("item_selected", callable_mp((BaseButton *)get_ok_button(), &BaseButton::set_disabled).bind(false)); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	vbox->add_child(results_tree, true); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | bool EditorHelpSearch::Runner::_is_class_disabled_by_feature_profile(const StringName &p_class) { | 
					
						
							|  |  |  | 	Ref<EditorFeatureProfile> profile = EditorFeatureProfileManager::get_singleton()->get_current_profile(); | 
					
						
							|  |  |  | 	if (profile.is_null()) { | 
					
						
							|  |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	StringName class_name = p_class; | 
					
						
							|  |  |  | 	while (class_name != StringName()) { | 
					
						
							| 
									
										
										
										
											2019-06-25 20:36:26 -03:00
										 |  |  | 		if (!ClassDB::class_exists(class_name)) { | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (profile->is_class_disabled(class_name)) { | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 			return true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		class_name = ClassDB::get_parent_class(class_name); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | bool EditorHelpSearch::Runner::_slice() { | 
					
						
							|  |  |  | 	bool phase_done = false; | 
					
						
							|  |  |  | 	switch (phase) { | 
					
						
							|  |  |  | 		case PHASE_MATCH_CLASSES_INIT: | 
					
						
							|  |  |  | 			phase_done = _phase_match_classes_init(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_MATCH_CLASSES: | 
					
						
							|  |  |  | 			phase_done = _phase_match_classes(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_CLASS_ITEMS_INIT: | 
					
						
							|  |  |  | 			phase_done = _phase_class_items_init(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_CLASS_ITEMS: | 
					
						
							|  |  |  | 			phase_done = _phase_class_items(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_MEMBER_ITEMS_INIT: | 
					
						
							|  |  |  | 			phase_done = _phase_member_items_init(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_MEMBER_ITEMS: | 
					
						
							|  |  |  | 			phase_done = _phase_member_items(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_SELECT_MATCH: | 
					
						
							|  |  |  | 			phase_done = _phase_select_match(); | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 		case PHASE_MAX: | 
					
						
							|  |  |  | 			return true; | 
					
						
							|  |  |  | 		default: | 
					
						
							| 
									
										
										
										
											2019-11-07 09:44:15 +01:00
										 |  |  | 			WARN_PRINT("Invalid or unhandled phase in EditorHelpSearch::Runner, aborting search."); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 			return true; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (phase_done) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		phase++; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_match_classes_init() { | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	iterator_doc = EditorHelp::get_doc_data()->class_list.begin(); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	matches.clear(); | 
					
						
							| 
									
										
										
										
											2020-04-02 01:20:12 +02:00
										 |  |  | 	matched_item = nullptr; | 
					
						
							| 
									
										
										
										
											2021-03-19 18:49:21 -03:00
										 |  |  | 	match_highest_score = 0; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 	terms = term.split_spaces(); | 
					
						
							|  |  |  | 	if (terms.is_empty()) { | 
					
						
							|  |  |  | 		terms.append(term); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_match_classes() { | 
					
						
							| 
									
										
										
										
											2022-09-19 13:26:50 +02:00
										 |  |  | 	if (!iterator_doc) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	DocData::ClassDoc &class_doc = iterator_doc->value; | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 	if (class_doc.name.is_empty()) { | 
					
						
							| 
									
										
										
										
											2022-09-10 19:34:26 +02:00
										 |  |  | 		++iterator_doc; | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-19 13:26:50 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 	if (!_is_class_disabled_by_feature_profile(class_doc.name)) { | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 		ClassMatch match; | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 		match.doc = &class_doc; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// Match class name.
 | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (search_flags & SEARCH_CLASSES) { | 
					
						
							| 
									
										
										
										
											2022-04-05 20:51:36 +01:00
										 |  |  | 			// If the search term is empty, add any classes which are not script docs or which don't start with
 | 
					
						
							| 
									
										
										
										
											2022-05-23 21:32:19 +02:00
										 |  |  | 			// a double-quotation. This will ensure that only C++ classes and explicitly named classes will
 | 
					
						
							| 
									
										
										
										
											2022-04-05 20:51:36 +01:00
										 |  |  | 			// be added.
 | 
					
						
							|  |  |  | 			match.name = (term.is_empty() && (!class_doc.is_script_doc || class_doc.name[0] != '\"')) || _match_string(term, class_doc.name); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 		// Match members only if the term is long enough, to avoid slow performance from building a large tree.
 | 
					
						
							|  |  |  | 		// Make an exception for annotations, since there are not that many of them.
 | 
					
						
							|  |  |  | 		if (term.length() > 1 || term == "@") { | 
					
						
							| 
									
										
										
										
											2021-09-20 21:49:02 -05:00
										 |  |  | 			if (search_flags & SEARCH_CONSTRUCTORS) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 				_match_method_name_and_push_back(class_doc.constructors, &match.constructors); | 
					
						
							| 
									
										
										
										
											2021-09-20 21:49:02 -05:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (search_flags & SEARCH_METHODS) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 				_match_method_name_and_push_back(class_doc.methods, &match.methods); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2021-09-20 21:49:02 -05:00
										 |  |  | 			if (search_flags & SEARCH_OPERATORS) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 				_match_method_name_and_push_back(class_doc.operators, &match.operators); | 
					
						
							| 
									
										
										
										
											2021-09-20 21:49:02 -05:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 			if (search_flags & SEARCH_SIGNALS) { | 
					
						
							|  |  |  | 				for (int i = 0; i < class_doc.signals.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 					if (_all_terms_in_name(class_doc.signals[i].name)) { | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 						match.signals.push_back(const_cast<DocData::MethodDoc *>(&class_doc.signals[i])); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (search_flags & SEARCH_CONSTANTS) { | 
					
						
							|  |  |  | 				for (int i = 0; i < class_doc.constants.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 					if (_all_terms_in_name(class_doc.constants[i].name)) { | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 						match.constants.push_back(const_cast<DocData::ConstantDoc *>(&class_doc.constants[i])); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (search_flags & SEARCH_PROPERTIES) { | 
					
						
							|  |  |  | 				for (int i = 0; i < class_doc.properties.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 					if (_all_terms_in_name(class_doc.properties[i].name)) { | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 						match.properties.push_back(const_cast<DocData::PropertyDoc *>(&class_doc.properties[i])); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (search_flags & SEARCH_THEME_ITEMS) { | 
					
						
							|  |  |  | 				for (int i = 0; i < class_doc.theme_properties.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | 					if (_all_terms_in_name(class_doc.theme_properties[i].name)) { | 
					
						
							| 
									
										
										
										
											2021-08-04 19:54:41 +03:00
										 |  |  | 						match.theme_properties.push_back(const_cast<DocData::ThemeItemDoc *>(&class_doc.theme_properties[i])); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 			if (search_flags & SEARCH_ANNOTATIONS) { | 
					
						
							|  |  |  | 				for (int i = 0; i < class_doc.annotations.size(); i++) { | 
					
						
							|  |  |  | 					if (_match_string(term, class_doc.annotations[i].name)) { | 
					
						
							|  |  |  | 						match.annotations.push_back(const_cast<DocData::MethodDoc *>(&class_doc.annotations[i])); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-06-06 22:04:25 -03:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-04-05 20:51:36 +01:00
										 |  |  | 		matches[class_doc.name] = match; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	++iterator_doc; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return !iterator_doc; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_class_items_init() { | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	iterator_match = matches.begin(); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	results_tree->clear(); | 
					
						
							|  |  |  | 	root_item = results_tree->create_item(); | 
					
						
							|  |  |  | 	class_items.clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_class_items() { | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 	if (!iterator_match) { | 
					
						
							| 
									
										
										
										
											2022-09-10 19:34:26 +02:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	ClassMatch &match = iterator_match->value; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (search_flags & SEARCH_SHOW_HIERARCHY) { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (match.required()) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 			_create_class_hierarchy(match); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		if (match.name) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 			_create_class_item(root_item, match.doc, false); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	++iterator_match; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return !iterator_match; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_member_items_init() { | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	iterator_match = matches.begin(); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_member_items() { | 
					
						
							| 
									
										
										
										
											2022-12-01 16:47:02 -05:00
										 |  |  | 	if (!iterator_match) { | 
					
						
							|  |  |  | 		return true; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	ClassMatch &match = iterator_match->value; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-10 19:34:26 +02:00
										 |  |  | 	if (!match.doc || match.doc->name.is_empty()) { | 
					
						
							|  |  |  | 		++iterator_match; | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 	TreeItem *parent_item = (search_flags & SEARCH_SHOW_HIERARCHY) ? class_items[match.doc->name] : root_item; | 
					
						
							| 
									
										
										
										
											2020-12-18 09:36:04 +03:00
										 |  |  | 	bool constructor_created = false; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	for (int i = 0; i < match.methods.size(); i++) { | 
					
						
							| 
									
										
										
										
											2020-12-18 09:36:04 +03:00
										 |  |  | 		String text = match.methods[i]->name; | 
					
						
							|  |  |  | 		if (!constructor_created) { | 
					
						
							|  |  |  | 			if (match.doc->name == match.methods[i]->name) { | 
					
						
							|  |  |  | 				text += " " + TTR("(constructors)"); | 
					
						
							|  |  |  | 				constructor_created = true; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			if (match.doc->name == match.methods[i]->name) { | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 		_create_method_item(parent_item, match.doc, text, match.methods[i]); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	for (int i = 0; i < match.signals.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 		_create_signal_item(parent_item, match.doc, match.signals[i]); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	for (int i = 0; i < match.constants.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 		_create_constant_item(parent_item, match.doc, match.constants[i]); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	for (int i = 0; i < match.properties.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 		_create_property_item(parent_item, match.doc, match.properties[i]); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	for (int i = 0; i < match.theme_properties.size(); i++) { | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 		_create_theme_property_item(parent_item, match.doc, match.theme_properties[i]); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 	for (int i = 0; i < match.annotations.size(); i++) { | 
					
						
							|  |  |  | 		// Hide the redundant leading @ symbol.
 | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 		_create_annotation_item(parent_item, match.doc, match.annotations[i]->name.substr(1), match.annotations[i]); | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 15:04:37 +02:00
										 |  |  | 	++iterator_match; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return !iterator_match; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_phase_select_match() { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (matched_item) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		matched_item->select(0); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-04 10:18:23 +02:00
										 |  |  | void EditorHelpSearch::Runner::_match_method_name_and_push_back(Vector<DocData::MethodDoc> &p_methods, Vector<DocData::MethodDoc *> *r_match_methods) { | 
					
						
							|  |  |  | 	// Constructors, Methods, Operators...
 | 
					
						
							|  |  |  | 	for (int i = 0; i < p_methods.size(); i++) { | 
					
						
							|  |  |  | 		String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? p_methods[i].name : p_methods[i].name.to_lower(); | 
					
						
							|  |  |  | 		if (_all_terms_in_name(method_name) || | 
					
						
							|  |  |  | 				(term.begins_with(".") && method_name.begins_with(term.substr(1))) || | 
					
						
							|  |  |  | 				(term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) || | 
					
						
							|  |  |  | 				(term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) { | 
					
						
							|  |  |  | 			r_match_methods->push_back(const_cast<DocData::MethodDoc *>(&p_methods[i])); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::_all_terms_in_name(String name) { | 
					
						
							|  |  |  | 	for (int i = 0; i < terms.size(); i++) { | 
					
						
							|  |  |  | 		if (!_match_string(terms[i], name)) { | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const { | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (search_flags & SEARCH_CASE_SENSITIVE) { | 
					
						
							| 
									
										
										
										
											2020-07-01 03:19:24 +12:00
										 |  |  | 		return p_string.find(p_term) > -1; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2020-07-01 03:19:24 +12:00
										 |  |  | 		return p_string.findn(p_term) > -1; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) { | 
					
						
							| 
									
										
										
										
											2021-03-19 18:49:21 -03:00
										 |  |  | 	float inverse_length = 1.f / float(p_text.length()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Favor types where search term is a substring close to the start of the type.
 | 
					
						
							|  |  |  | 	float w = 0.5f; | 
					
						
							|  |  |  | 	int pos = p_text.findn(term); | 
					
						
							|  |  |  | 	float score = (pos > -1) ? 1.0f - w * MIN(1, 3 * pos * inverse_length) : MAX(0.f, .9f - w); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Favor shorter items: they resemble the search term more.
 | 
					
						
							|  |  |  | 	w = 0.1f; | 
					
						
							|  |  |  | 	score *= (1 - w) + w * (term.length() * inverse_length); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (match_highest_score == 0 || score > match_highest_score) { | 
					
						
							|  |  |  | 		matched_item = p_item; | 
					
						
							|  |  |  | 		match_highest_score = score; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | String EditorHelpSearch::Runner::_build_method_tooltip(const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) const { | 
					
						
							|  |  |  | 	String tooltip = p_doc->return_type + " " + p_class_doc->name + "." + p_doc->name + "("; | 
					
						
							|  |  |  | 	for (int i = 0; i < p_doc->arguments.size(); i++) { | 
					
						
							|  |  |  | 		const DocData::ArgumentDoc &arg = p_doc->arguments[i]; | 
					
						
							|  |  |  | 		tooltip += arg.type + " " + arg.name; | 
					
						
							|  |  |  | 		if (!arg.default_value.is_empty()) { | 
					
						
							|  |  |  | 			tooltip += " = " + arg.default_value; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (i < p_doc->arguments.size() - 1) { | 
					
						
							|  |  |  | 			tooltip += ", "; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	tooltip += ")"; | 
					
						
							|  |  |  | 	return tooltip; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | TreeItem *EditorHelpSearch::Runner::_create_class_hierarchy(const ClassMatch &p_match) { | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 	if (p_match.doc->name.is_empty()) { | 
					
						
							|  |  |  | 		return nullptr; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	if (class_items.has(p_match.doc->name)) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		return class_items[p_match.doc->name]; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Ensure parent nodes are created first.
 | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 	TreeItem *parent_item = root_item; | 
					
						
							| 
									
										
										
										
											2021-12-09 03:42:46 -06:00
										 |  |  | 	if (!p_match.doc->inherits.is_empty()) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		if (class_items.has(p_match.doc->inherits)) { | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 			parent_item = class_items[p_match.doc->inherits]; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			ClassMatch &base_match = matches[p_match.doc->inherits]; | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 			if (base_match.doc) { | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 				parent_item = _create_class_hierarchy(base_match); | 
					
						
							| 
									
										
										
										
											2021-10-29 18:42:57 -07:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-29 12:53:28 +03:00
										 |  |  | 	TreeItem *class_item = _create_class_item(parent_item, p_match.doc, !p_match.name); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	class_items[p_match.doc->name] = class_item; | 
					
						
							|  |  |  | 	return class_item; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TreeItem *EditorHelpSearch::Runner::_create_class_item(TreeItem *p_parent, const DocData::ClassDoc *p_doc, bool p_gray) { | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	Ref<Texture2D> icon = empty_icon; | 
					
						
							| 
									
										
										
										
											2022-02-06 15:53:53 +01:00
										 |  |  | 	if (ui_service->has_theme_icon(p_doc->name, SNAME("EditorIcons"))) { | 
					
						
							|  |  |  | 		icon = ui_service->get_theme_icon(p_doc->name, SNAME("EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} else if (ClassDB::class_exists(p_doc->name) && ClassDB::is_parent_class(p_doc->name, "Object")) { | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 		icon = ui_service->get_theme_icon(SNAME("Object"), SNAME("EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2022-03-07 21:50:02 +08:00
										 |  |  | 	String tooltip = DTR(p_doc->brief_description.strip_edges()); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TreeItem *item = results_tree->create_item(p_parent); | 
					
						
							|  |  |  | 	item->set_icon(0, icon); | 
					
						
							|  |  |  | 	item->set_text(0, p_doc->name); | 
					
						
							|  |  |  | 	item->set_text(1, TTR("Class")); | 
					
						
							| 
									
										
										
										
											2022-08-29 15:55:49 +02:00
										 |  |  | 	item->set_tooltip_text(0, tooltip); | 
					
						
							|  |  |  | 	item->set_tooltip_text(1, tooltip); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	item->set_metadata(0, "class_name:" + p_doc->name); | 
					
						
							|  |  |  | 	if (p_gray) { | 
					
						
							|  |  |  | 		item->set_custom_color(0, disabled_color); | 
					
						
							|  |  |  | 		item->set_custom_color(1, disabled_color); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	if (p_doc->is_deprecated) { | 
					
						
							|  |  |  | 		Ref<Texture2D> error_icon = ui_service->get_theme_icon("StatusError", SNAME("EditorIcons")); | 
					
						
							|  |  |  | 		item->add_button(0, error_icon, 0, false, TTR("This class is marked as deprecated.")); | 
					
						
							|  |  |  | 	} else if (p_doc->is_experimental) { | 
					
						
							|  |  |  | 		Ref<Texture2D> warning_icon = ui_service->get_theme_icon("NodeWarning", SNAME("EditorIcons")); | 
					
						
							|  |  |  | 		item->add_button(0, warning_icon, 0, false, TTR("This class is marked as experimental.")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	_match_item(item, p_doc->name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return item; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-18 09:36:04 +03:00
										 |  |  | TreeItem *EditorHelpSearch::Runner::_create_method_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) { | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 	String tooltip = _build_method_tooltip(p_class_doc, p_doc); | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	return _create_member_item(p_parent, p_class_doc->name, "MemberMethod", p_doc->name, p_text, TTRC("Method"), "method", tooltip, p_doc->is_deprecated, p_doc->is_experimental); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TreeItem *EditorHelpSearch::Runner::_create_signal_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::MethodDoc *p_doc) { | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | 	String tooltip = _build_method_tooltip(p_class_doc, p_doc); | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	return _create_member_item(p_parent, p_class_doc->name, "MemberSignal", p_doc->name, p_doc->name, TTRC("Signal"), "signal", tooltip, p_doc->is_deprecated, p_doc->is_experimental); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | TreeItem *EditorHelpSearch::Runner::_create_annotation_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const String &p_text, const DocData::MethodDoc *p_doc) { | 
					
						
							|  |  |  | 	String tooltip = _build_method_tooltip(p_class_doc, p_doc); | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	return _create_member_item(p_parent, p_class_doc->name, "MemberAnnotation", p_doc->name, p_text, TTRC("Annotation"), "annotation", tooltip, p_doc->is_deprecated, p_doc->is_experimental); | 
					
						
							| 
									
										
										
										
											2022-09-01 18:11:19 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | TreeItem *EditorHelpSearch::Runner::_create_constant_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ConstantDoc *p_doc) { | 
					
						
							|  |  |  | 	String tooltip = p_class_doc->name + "." + p_doc->name; | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	return _create_member_item(p_parent, p_class_doc->name, "MemberConstant", p_doc->name, p_doc->name, TTRC("Constant"), "constant", tooltip, p_doc->is_deprecated, p_doc->is_experimental); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TreeItem *EditorHelpSearch::Runner::_create_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::PropertyDoc *p_doc) { | 
					
						
							|  |  |  | 	String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name; | 
					
						
							|  |  |  | 	tooltip += "\n    " + p_class_doc->name + "." + p_doc->setter + "(value) setter"; | 
					
						
							|  |  |  | 	tooltip += "\n    " + p_class_doc->name + "." + p_doc->getter + "() getter"; | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	return _create_member_item(p_parent, p_class_doc->name, "MemberProperty", p_doc->name, p_doc->name, TTRC("Property"), "property", tooltip, p_doc->is_deprecated, p_doc->is_experimental); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-04 19:54:41 +03:00
										 |  |  | TreeItem *EditorHelpSearch::Runner::_create_theme_property_item(TreeItem *p_parent, const DocData::ClassDoc *p_class_doc, const DocData::ThemeItemDoc *p_doc) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	String tooltip = p_doc->type + " " + p_class_doc->name + "." + p_doc->name; | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	return _create_member_item(p_parent, p_class_doc->name, "MemberTheme", p_doc->name, p_doc->name, TTRC("Theme Property"), "theme_item", tooltip, false, false); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | TreeItem *EditorHelpSearch::Runner::_create_member_item(TreeItem *p_parent, const String &p_class_name, const String &p_icon, const String &p_name, const String &p_text, const String &p_type, const String &p_metatype, const String &p_tooltip, bool is_deprecated, bool is_experimental) { | 
					
						
							| 
									
										
										
										
											2019-06-11 15:43:37 -03:00
										 |  |  | 	Ref<Texture2D> icon; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	String text; | 
					
						
							|  |  |  | 	if (search_flags & SEARCH_SHOW_HIERARCHY) { | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 		icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-12-18 09:36:04 +03:00
										 |  |  | 		text = p_text; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 		icon = ui_service->get_theme_icon(p_icon, SNAME("EditorIcons")); | 
					
						
							| 
									
										
										
										
											2020-12-18 09:36:04 +03:00
										 |  |  | 		text = p_class_name + "." + p_text; | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TreeItem *item = results_tree->create_item(p_parent); | 
					
						
							|  |  |  | 	item->set_icon(0, icon); | 
					
						
							|  |  |  | 	item->set_text(0, text); | 
					
						
							| 
									
										
										
										
											2019-12-28 10:33:01 +08:00
										 |  |  | 	item->set_text(1, TTRGET(p_type)); | 
					
						
							| 
									
										
										
										
											2022-08-29 15:55:49 +02:00
										 |  |  | 	item->set_tooltip_text(0, p_tooltip); | 
					
						
							|  |  |  | 	item->set_tooltip_text(1, p_tooltip); | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	item->set_metadata(0, "class_" + p_metatype + ":" + p_class_name + ":" + p_name); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 07:17:25 +01:00
										 |  |  | 	if (is_deprecated) { | 
					
						
							|  |  |  | 		Ref<Texture2D> error_icon = ui_service->get_theme_icon("StatusError", SNAME("EditorIcons")); | 
					
						
							|  |  |  | 		item->add_button(0, error_icon, 0, false, TTR("This member is marked as deprecated.")); | 
					
						
							|  |  |  | 	} else if (is_experimental) { | 
					
						
							|  |  |  | 		Ref<Texture2D> warning_icon = ui_service->get_theme_icon("NodeWarning", SNAME("EditorIcons")); | 
					
						
							|  |  |  | 		item->add_button(0, warning_icon, 0, false, TTR("This member is marked as experimental.")); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	_match_item(item, p_name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return item; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool EditorHelpSearch::Runner::work(uint64_t slot) { | 
					
						
							|  |  |  | 	// Return true when the search has been completed, otherwise false.
 | 
					
						
							|  |  |  | 	const uint64_t until = OS::get_singleton()->get_ticks_usec() + slot; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 	while (!_slice()) { | 
					
						
							|  |  |  | 		if (OS::get_singleton()->get_ticks_usec() > until) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 			return false; | 
					
						
							| 
									
										
										
										
											2020-05-14 16:41:43 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-08 15:07:33 -05:00
										 |  |  | EditorHelpSearch::Runner::Runner(Control *p_icon_service, Tree *p_results_tree, const String &p_term, int p_search_flags) : | 
					
						
							|  |  |  | 		ui_service(p_icon_service), | 
					
						
							|  |  |  | 		results_tree(p_results_tree), | 
					
						
							|  |  |  | 		term((p_search_flags & SEARCH_CASE_SENSITIVE) == 0 ? p_term.strip_edges().to_lower() : p_term.strip_edges()), | 
					
						
							|  |  |  | 		search_flags(p_search_flags), | 
					
						
							| 
									
										
										
										
											2021-07-17 18:22:52 -03:00
										 |  |  | 		empty_icon(ui_service->get_theme_icon(SNAME("ArrowRight"), SNAME("EditorIcons"))), | 
					
						
							|  |  |  | 		disabled_color(ui_service->get_theme_color(SNAME("disabled_font_color"), SNAME("Editor"))) { | 
					
						
							| 
									
										
										
										
											2017-12-11 00:56:49 +01:00
										 |  |  | } |