feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -39,37 +39,72 @@
|
|||
#include "editor/plugins/script_editor_plugin.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "editor/themes/editor_theme_manager.h"
|
||||
#include "scene/gui/line_edit.h"
|
||||
#include "scene/gui/menu_button.h"
|
||||
#include "scene/gui/separator.h"
|
||||
#include "scene/resources/font.h"
|
||||
|
||||
void GotoLineDialog::popup_find_line(CodeEdit *p_edit) {
|
||||
text_editor = p_edit;
|
||||
void GotoLinePopup::popup_find_line(CodeTextEditor *p_text_editor) {
|
||||
text_editor = p_text_editor;
|
||||
|
||||
// Add 1 because text_editor->get_caret_line() starts from 0, but the editor user interface starts from 1.
|
||||
line->set_text(itos(text_editor->get_caret_line() + 1));
|
||||
line->select_all();
|
||||
popup_centered(Size2(180, 80) * EDSCALE);
|
||||
line->grab_focus();
|
||||
original_state = text_editor->get_navigation_state();
|
||||
|
||||
// Add 1 because the TextEdit starts from 0, but the editor user interface starts from 1.
|
||||
TextEdit *text_edit = text_editor->get_text_editor();
|
||||
int original_line = text_edit->get_caret_line() + 1;
|
||||
line_input->set_text(itos(original_line));
|
||||
text_editor->set_preview_navigation_change(true);
|
||||
|
||||
Rect2i parent_rect = text_editor->get_global_rect();
|
||||
Point2i centered_pos(parent_rect.get_center().x - get_contents_minimum_size().x / 2.0, parent_rect.position.y);
|
||||
popup_on_parent(Rect2i(centered_pos, Size2()));
|
||||
reset_size();
|
||||
line_input->grab_focus();
|
||||
}
|
||||
|
||||
int GotoLineDialog::get_line() const {
|
||||
return line->get_text().to_int();
|
||||
}
|
||||
|
||||
void GotoLineDialog::ok_pressed() {
|
||||
// Subtract 1 because the editor user interface starts from 1, but text_editor->set_caret_line(n) starts from 0.
|
||||
const int line_number = get_line() - 1;
|
||||
if (line_number < 0 || line_number >= text_editor->get_line_count()) {
|
||||
void GotoLinePopup::_goto_line() {
|
||||
if (line_input->get_text().is_empty()) {
|
||||
return;
|
||||
}
|
||||
text_editor->remove_secondary_carets();
|
||||
text_editor->unfold_line(line_number);
|
||||
text_editor->set_caret_line(line_number);
|
||||
|
||||
PackedStringArray line_col_strings = line_input->get_text().split(":");
|
||||
// Subtract 1 because the editor user interface starts from 1, but the TextEdit starts from 0.
|
||||
const int line_number = line_col_strings[0].to_int() - 1;
|
||||
if (line_number < 0 || line_number >= text_editor->get_text_editor()->get_line_count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int column_number = 0;
|
||||
if (line_col_strings.size() >= 2) {
|
||||
column_number = line_col_strings[1].to_int() - 1;
|
||||
}
|
||||
text_editor->goto_line_centered(line_number, column_number);
|
||||
}
|
||||
|
||||
void GotoLinePopup::_submit() {
|
||||
_goto_line();
|
||||
hide();
|
||||
}
|
||||
|
||||
GotoLineDialog::GotoLineDialog() {
|
||||
void GotoLinePopup::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
if (!is_visible()) {
|
||||
text_editor->set_preview_navigation_change(false);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void GotoLinePopup::_input_from_window(const Ref<InputEvent> &p_event) {
|
||||
if (p_event->is_action_pressed(SNAME("ui_cancel"), false, true)) {
|
||||
// Cancelled, go back to original state.
|
||||
text_editor->set_edit_state(original_state);
|
||||
}
|
||||
PopupPanel::_input_from_window(p_event);
|
||||
}
|
||||
|
||||
GotoLinePopup::GotoLinePopup() {
|
||||
set_title(TTR("Go to Line"));
|
||||
|
||||
VBoxContainer *vbc = memnew(VBoxContainer);
|
||||
|
|
@ -83,14 +118,12 @@ GotoLineDialog::GotoLineDialog() {
|
|||
l->set_text(TTR("Line Number:"));
|
||||
vbc->add_child(l);
|
||||
|
||||
line = memnew(LineEdit);
|
||||
vbc->add_child(line);
|
||||
register_text_enter(line);
|
||||
text_editor = nullptr;
|
||||
|
||||
line_label = nullptr;
|
||||
|
||||
set_hide_on_ok(false);
|
||||
line_input = memnew(LineEdit);
|
||||
line_input->set_custom_minimum_size(Size2(100, 0) * EDSCALE);
|
||||
line_input->set_select_all_on_focus(true);
|
||||
line_input->connect(SceneStringName(text_changed), callable_mp(this, &GotoLinePopup::_goto_line).unbind(1));
|
||||
line_input->connect(SceneStringName(text_submitted), callable_mp(this, &GotoLinePopup::_submit).unbind(1));
|
||||
vbc->add_child(line_input);
|
||||
}
|
||||
|
||||
void FindReplaceBar::_notification(int p_what) {
|
||||
|
|
@ -102,16 +135,17 @@ void FindReplaceBar::_notification(int p_what) {
|
|||
[[fallthrough]];
|
||||
}
|
||||
case NOTIFICATION_READY: {
|
||||
find_prev->set_icon(get_editor_theme_icon(SNAME("MoveUp")));
|
||||
find_next->set_icon(get_editor_theme_icon(SNAME("MoveDown")));
|
||||
find_prev->set_button_icon(get_editor_theme_icon(SNAME("MoveUp")));
|
||||
find_next->set_button_icon(get_editor_theme_icon(SNAME("MoveDown")));
|
||||
hide_button->set_texture_normal(get_editor_theme_icon(SNAME("Close")));
|
||||
hide_button->set_texture_hover(get_editor_theme_icon(SNAME("Close")));
|
||||
hide_button->set_texture_pressed(get_editor_theme_icon(SNAME("Close")));
|
||||
hide_button->set_custom_minimum_size(hide_button->get_texture_normal()->get_size());
|
||||
_update_toggle_replace_button(replace_text->is_visible_in_tree());
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
set_process_unhandled_input(is_visible_in_tree());
|
||||
set_process_input(is_visible_in_tree());
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
|
|
@ -127,11 +161,11 @@ void FindReplaceBar::_notification(int p_what) {
|
|||
}
|
||||
}
|
||||
|
||||
void FindReplaceBar::unhandled_input(const Ref<InputEvent> &p_event) {
|
||||
// Implemented in input(..) as the LineEdit consumes the Escape pressed key.
|
||||
void FindReplaceBar::input(const Ref<InputEvent> &p_event) {
|
||||
ERR_FAIL_COND(p_event.is_null());
|
||||
|
||||
Ref<InputEventKey> k = p_event;
|
||||
|
||||
if (k.is_valid() && k->is_action_pressed(SNAME("ui_cancel"), false, true)) {
|
||||
Control *focus_owner = get_viewport()->gui_get_focus_owner();
|
||||
|
||||
|
|
@ -142,13 +176,6 @@ void FindReplaceBar::unhandled_input(const Ref<InputEvent> &p_event) {
|
|||
}
|
||||
}
|
||||
|
||||
void FindReplaceBar::_focus_lost() {
|
||||
if (Input::get_singleton()->is_action_pressed(SNAME("ui_cancel"))) {
|
||||
// Unfocused after pressing Escape, so hide the bar.
|
||||
_hide_bar(true);
|
||||
}
|
||||
}
|
||||
|
||||
void FindReplaceBar::_update_flags(bool p_direction_backwards) {
|
||||
flags = 0;
|
||||
|
||||
|
|
@ -175,6 +202,8 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col)
|
|||
text_editor->unfold_line(pos.y);
|
||||
text_editor->select(pos.y, pos.x, pos.y, pos.x + text.length());
|
||||
text_editor->center_viewport_to_caret(0);
|
||||
text_editor->set_code_hint("");
|
||||
text_editor->cancel_code_completion();
|
||||
|
||||
line_col_changed_for_result = true;
|
||||
}
|
||||
|
|
@ -528,8 +557,8 @@ bool FindReplaceBar::search_next() {
|
|||
return _search(flags, line, col);
|
||||
}
|
||||
|
||||
void FindReplaceBar::_hide_bar(bool p_force_focus) {
|
||||
if (replace_text->has_focus() || search_text->has_focus() || p_force_focus) {
|
||||
void FindReplaceBar::_hide_bar() {
|
||||
if (replace_text->has_focus() || search_text->has_focus()) {
|
||||
text_editor->grab_focus();
|
||||
}
|
||||
|
||||
|
|
@ -539,6 +568,14 @@ void FindReplaceBar::_hide_bar(bool p_force_focus) {
|
|||
hide();
|
||||
}
|
||||
|
||||
void FindReplaceBar::_update_toggle_replace_button(bool p_replace_visible) {
|
||||
String tooltip = p_replace_visible ? TTR("Hide Replace") : TTR("Show Replace");
|
||||
String shortcut = ED_GET_SHORTCUT(p_replace_visible ? "script_text_editor/find" : "script_text_editor/replace")->get_as_text();
|
||||
toggle_replace_button->set_tooltip_text(vformat("%s (%s)", tooltip, shortcut));
|
||||
StringName rtl_compliant_arrow = is_layout_rtl() ? SNAME("GuiTreeArrowLeft") : SNAME("GuiTreeArrowRight");
|
||||
toggle_replace_button->set_button_icon(get_editor_theme_icon(p_replace_visible ? SNAME("GuiTreeArrowDown") : rtl_compliant_arrow));
|
||||
}
|
||||
|
||||
void FindReplaceBar::_show_search(bool p_with_replace, bool p_show_only) {
|
||||
show();
|
||||
if (p_show_only) {
|
||||
|
|
@ -582,6 +619,7 @@ void FindReplaceBar::popup_search(bool p_show_only) {
|
|||
hbc_button_replace->hide();
|
||||
hbc_option_replace->hide();
|
||||
selection_only->set_pressed(false);
|
||||
_update_toggle_replace_button(false);
|
||||
|
||||
_show_search(false, p_show_only);
|
||||
}
|
||||
|
|
@ -591,6 +629,7 @@ void FindReplaceBar::popup_replace() {
|
|||
replace_text->show();
|
||||
hbc_button_replace->show();
|
||||
hbc_option_replace->show();
|
||||
_update_toggle_replace_button(true);
|
||||
}
|
||||
|
||||
selection_only->set_pressed(text_editor->has_selection(0) && text_editor->get_selection_from_line(0) < text_editor->get_selection_to_line(0));
|
||||
|
|
@ -644,6 +683,11 @@ void FindReplaceBar::_replace_text_submitted(const String &p_text) {
|
|||
}
|
||||
}
|
||||
|
||||
void FindReplaceBar::_toggle_replace_pressed() {
|
||||
bool replace_visible = replace_text->is_visible_in_tree();
|
||||
replace_visible ? popup_search(true) : popup_replace();
|
||||
}
|
||||
|
||||
String FindReplaceBar::get_search_text() const {
|
||||
return search_text->get_text();
|
||||
}
|
||||
|
|
@ -702,6 +746,12 @@ void FindReplaceBar::_bind_methods() {
|
|||
}
|
||||
|
||||
FindReplaceBar::FindReplaceBar() {
|
||||
toggle_replace_button = memnew(Button);
|
||||
add_child(toggle_replace_button);
|
||||
toggle_replace_button->set_flat(true);
|
||||
toggle_replace_button->set_focus_mode(FOCUS_NONE);
|
||||
toggle_replace_button->connect(SceneStringName(pressed), callable_mp(this, &FindReplaceBar::_toggle_replace_pressed));
|
||||
|
||||
vbc_lineedit = memnew(VBoxContainer);
|
||||
add_child(vbc_lineedit);
|
||||
vbc_lineedit->set_alignment(BoxContainer::ALIGNMENT_CENTER);
|
||||
|
|
@ -725,13 +775,13 @@ FindReplaceBar::FindReplaceBar() {
|
|||
|
||||
// Search toolbar
|
||||
search_text = memnew(LineEdit);
|
||||
search_text->set_keep_editing_on_text_submit(true);
|
||||
vbc_lineedit->add_child(search_text);
|
||||
search_text->set_placeholder(TTR("Find"));
|
||||
search_text->set_tooltip_text(TTR("Find"));
|
||||
search_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
search_text->connect(SceneStringName(text_changed), callable_mp(this, &FindReplaceBar::_search_text_changed));
|
||||
search_text->connect("text_submitted", callable_mp(this, &FindReplaceBar::_search_text_submitted));
|
||||
search_text->connect(SceneStringName(focus_exited), callable_mp(this, &FindReplaceBar::_focus_lost));
|
||||
search_text->connect(SceneStringName(text_submitted), callable_mp(this, &FindReplaceBar::_search_text_submitted));
|
||||
|
||||
matches_label = memnew(Label);
|
||||
hbc_button_search->add_child(matches_label);
|
||||
|
|
@ -755,13 +805,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);
|
||||
|
|
@ -769,8 +819,7 @@ FindReplaceBar::FindReplaceBar() {
|
|||
replace_text->set_placeholder(TTR("Replace"));
|
||||
replace_text->set_tooltip_text(TTR("Replace"));
|
||||
replace_text->set_custom_minimum_size(Size2(100 * EDSCALE, 0));
|
||||
replace_text->connect("text_submitted", callable_mp(this, &FindReplaceBar::_replace_text_submitted));
|
||||
replace_text->connect(SceneStringName(focus_exited), callable_mp(this, &FindReplaceBar::_focus_lost));
|
||||
replace_text->connect(SceneStringName(text_submitted), callable_mp(this, &FindReplaceBar::_replace_text_submitted));
|
||||
|
||||
replace = memnew(Button);
|
||||
hbc_button_replace->add_child(replace);
|
||||
|
|
@ -786,19 +835,19 @@ 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);
|
||||
hide_button->set_tooltip_text(TTR("Hide"));
|
||||
hide_button->set_focus_mode(FOCUS_NONE);
|
||||
hide_button->connect(SceneStringName(pressed), callable_mp(this, &FindReplaceBar::_hide_bar).bind(false));
|
||||
hide_button->connect(SceneStringName(pressed), callable_mp(this, &FindReplaceBar::_hide_bar));
|
||||
hide_button->set_v_size_flags(SIZE_SHRINK_CENTER);
|
||||
}
|
||||
|
||||
/*** CODE EDITOR ****/
|
||||
|
||||
static constexpr float ZOOM_FACTOR_PRESETS[7] = { 0.25f, 0.5f, 0.75f, 1.0f, 1.5f, 2.0f, 3.0f };
|
||||
static constexpr float ZOOM_FACTOR_PRESETS[8] = { 0.5f, 0.75f, 0.9f, 1.0f, 1.1f, 1.25f, 1.5f, 2.0f };
|
||||
|
||||
// This function should be used to handle shortcuts that could otherwise
|
||||
// be handled too late if they weren't handled here.
|
||||
|
|
@ -807,7 +856,7 @@ void CodeTextEditor::input(const Ref<InputEvent> &event) {
|
|||
|
||||
const Ref<InputEventKey> key_event = event;
|
||||
|
||||
if (!key_event.is_valid()) {
|
||||
if (key_event.is_null()) {
|
||||
return;
|
||||
}
|
||||
if (!key_event->is_pressed()) {
|
||||
|
|
@ -875,12 +924,14 @@ void CodeTextEditor::_text_editor_gui_input(const Ref<InputEvent> &p_event) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef ANDROID_ENABLED
|
||||
Ref<InputEventMagnifyGesture> magnify_gesture = p_event;
|
||||
if (magnify_gesture.is_valid()) {
|
||||
_zoom_to(zoom_factor * powf(magnify_gesture->get_factor(), 0.25f));
|
||||
accept_event();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Ref<InputEventKey> k = p_event;
|
||||
|
||||
|
|
@ -994,6 +1045,9 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptLanguage::CodeCo
|
|||
tex = get_editor_theme_icon(p_option.display);
|
||||
} else {
|
||||
tex = EditorNode::get_singleton()->get_class_icon(p_option.display);
|
||||
if (tex.is_null()) {
|
||||
tex = get_editor_theme_icon(SNAME("Object"));
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_ENUM:
|
||||
|
|
@ -1006,7 +1060,7 @@ Ref<Texture2D> CodeTextEditor::_get_completion_icon(const ScriptLanguage::CodeCo
|
|||
tex = get_editor_theme_icon(SNAME("NodePath"));
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE:
|
||||
tex = get_editor_theme_icon(SNAME("Variant"));
|
||||
tex = get_editor_theme_icon(SNAME("LocalVariable"));
|
||||
break;
|
||||
case ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT:
|
||||
tex = get_editor_theme_icon(SNAME("MemberConstant"));
|
||||
|
|
@ -1065,6 +1119,9 @@ void CodeTextEditor::update_editor_settings() {
|
|||
text_editor->set_draw_spaces(EDITOR_GET("text_editor/appearance/whitespace/draw_spaces"));
|
||||
text_editor->add_theme_constant_override("line_spacing", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));
|
||||
|
||||
// Behavior: General
|
||||
text_editor->set_empty_selection_clipboard_enabled(EDITOR_GET("text_editor/behavior/general/empty_selection_clipboard"));
|
||||
|
||||
// Behavior: Navigation
|
||||
text_editor->set_scroll_past_end_of_file_enabled(EDITOR_GET("text_editor/behavior/navigation/scroll_past_end_of_file"));
|
||||
text_editor->set_smooth_scroll_enabled(EDITOR_GET("text_editor/behavior/navigation/smooth_scrolling"));
|
||||
|
|
@ -1085,7 +1142,8 @@ void CodeTextEditor::update_editor_settings() {
|
|||
text_editor->set_code_hint_draw_below(EDITOR_GET("text_editor/completion/put_callhint_tooltip_below_current_line"));
|
||||
code_complete_enabled = EDITOR_GET("text_editor/completion/code_complete_enabled");
|
||||
code_complete_timer->set_wait_time(EDITOR_GET("text_editor/completion/code_complete_delay"));
|
||||
idle->set_wait_time(EDITOR_GET("text_editor/completion/idle_parse_delay"));
|
||||
idle_time = EDITOR_GET("text_editor/completion/idle_parse_delay");
|
||||
idle_time_with_errors = EDITOR_GET("text_editor/completion/idle_parse_delay_with_errors_found");
|
||||
|
||||
// Appearance: Guidelines
|
||||
if (EDITOR_GET("text_editor/appearance/guidelines/show_line_length_guidelines")) {
|
||||
|
|
@ -1296,23 +1354,35 @@ void CodeTextEditor::toggle_inline_comment(const String &delimiter) {
|
|||
text_editor->end_complex_operation();
|
||||
}
|
||||
|
||||
void CodeTextEditor::goto_line(int p_line) {
|
||||
void CodeTextEditor::goto_line(int p_line, int p_column) {
|
||||
text_editor->remove_secondary_carets();
|
||||
text_editor->deselect();
|
||||
text_editor->unfold_line(p_line);
|
||||
callable_mp((TextEdit *)text_editor, &TextEdit::set_caret_line).call_deferred(p_line, true, true, 0, 0);
|
||||
text_editor->unfold_line(CLAMP(p_line, 0, text_editor->get_line_count() - 1));
|
||||
text_editor->set_caret_line(p_line, false);
|
||||
text_editor->set_caret_column(p_column, false);
|
||||
text_editor->set_code_hint("");
|
||||
text_editor->cancel_code_completion();
|
||||
// Defer in case the CodeEdit was just created and needs to be resized.
|
||||
callable_mp((TextEdit *)text_editor, &TextEdit::adjust_viewport_to_caret).call_deferred(0);
|
||||
}
|
||||
|
||||
void CodeTextEditor::goto_line_selection(int p_line, int p_begin, int p_end) {
|
||||
text_editor->remove_secondary_carets();
|
||||
text_editor->unfold_line(p_line);
|
||||
callable_mp((TextEdit *)text_editor, &TextEdit::set_caret_line).call_deferred(p_line, true, true, 0, 0);
|
||||
callable_mp((TextEdit *)text_editor, &TextEdit::set_caret_column).call_deferred(p_begin, true, 0);
|
||||
text_editor->unfold_line(CLAMP(p_line, 0, text_editor->get_line_count() - 1));
|
||||
text_editor->select(p_line, p_begin, p_line, p_end);
|
||||
text_editor->set_code_hint("");
|
||||
text_editor->cancel_code_completion();
|
||||
callable_mp((TextEdit *)text_editor, &TextEdit::adjust_viewport_to_caret).call_deferred(0);
|
||||
}
|
||||
|
||||
void CodeTextEditor::goto_line_centered(int p_line) {
|
||||
goto_line(p_line);
|
||||
void CodeTextEditor::goto_line_centered(int p_line, int p_column) {
|
||||
text_editor->remove_secondary_carets();
|
||||
text_editor->deselect();
|
||||
text_editor->unfold_line(CLAMP(p_line, 0, text_editor->get_line_count() - 1));
|
||||
text_editor->set_caret_line(p_line, false);
|
||||
text_editor->set_caret_column(p_column, false);
|
||||
text_editor->set_code_hint("");
|
||||
text_editor->cancel_code_completion();
|
||||
callable_mp((TextEdit *)text_editor, &TextEdit::center_viewport_to_caret).call_deferred(0);
|
||||
}
|
||||
|
||||
|
|
@ -1346,6 +1416,20 @@ void CodeTextEditor::store_previous_state() {
|
|||
previous_state = get_navigation_state();
|
||||
}
|
||||
|
||||
bool CodeTextEditor::is_previewing_navigation_change() const {
|
||||
return preview_navigation_change;
|
||||
}
|
||||
|
||||
void CodeTextEditor::set_preview_navigation_change(bool p_preview) {
|
||||
if (preview_navigation_change == p_preview) {
|
||||
return;
|
||||
}
|
||||
preview_navigation_change = p_preview;
|
||||
if (!preview_navigation_change) {
|
||||
emit_signal("navigation_preview_ended");
|
||||
}
|
||||
}
|
||||
|
||||
void CodeTextEditor::set_edit_state(const Variant &p_state) {
|
||||
Dictionary state = p_state;
|
||||
|
||||
|
|
@ -1440,21 +1524,15 @@ void CodeTextEditor::goto_error() {
|
|||
corrected_column -= tab_count * (indent_size - 1);
|
||||
}
|
||||
|
||||
if (text_editor->get_line_count() != error_line) {
|
||||
text_editor->unfold_line(error_line);
|
||||
}
|
||||
text_editor->remove_secondary_carets();
|
||||
text_editor->set_caret_line(error_line);
|
||||
text_editor->set_caret_column(corrected_column);
|
||||
text_editor->center_viewport_to_caret();
|
||||
goto_line_centered(error_line, corrected_column);
|
||||
}
|
||||
}
|
||||
|
||||
void CodeTextEditor::_update_text_editor_theme() {
|
||||
emit_signal(SNAME("load_theme_settings"));
|
||||
|
||||
error_button->set_icon(get_editor_theme_icon(SNAME("StatusError")));
|
||||
warning_button->set_icon(get_editor_theme_icon(SNAME("NodeWarning")));
|
||||
error_button->set_button_icon(get_editor_theme_icon(SNAME("StatusError")));
|
||||
warning_button->set_button_icon(get_editor_theme_icon(SNAME("NodeWarning")));
|
||||
|
||||
Ref<Font> status_bar_font = get_theme_font(SNAME("status_source"), EditorStringName(EditorFonts));
|
||||
int status_bar_font_size = get_theme_font_size(SNAME("status_source_size"), EditorStringName(EditorFonts));
|
||||
|
|
@ -1545,7 +1623,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();
|
||||
}
|
||||
|
||||
|
|
@ -1558,6 +1637,11 @@ void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
|
|||
|
||||
void CodeTextEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY: {
|
||||
set_error_count(0);
|
||||
set_warning_count(0);
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
if (toggle_scripts_button->is_visible()) {
|
||||
update_toggle_scripts_button();
|
||||
|
|
@ -1583,8 +1667,11 @@ void CodeTextEditor::_notification(int p_what) {
|
|||
void CodeTextEditor::set_error_count(int p_error_count) {
|
||||
error_button->set_text(itos(p_error_count));
|
||||
error_button->set_visible(p_error_count > 0);
|
||||
if (!p_error_count) {
|
||||
if (p_error_count > 0) {
|
||||
_set_show_errors_panel(false);
|
||||
idle->set_wait_time(idle_time_with_errors); // Parsing should happen sooner.
|
||||
} else {
|
||||
idle->set_wait_time(idle_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1690,8 +1777,7 @@ void CodeTextEditor::_zoom_to(float p_zoom_factor) {
|
|||
}
|
||||
|
||||
void CodeTextEditor::set_zoom_factor(float p_zoom_factor) {
|
||||
int preset_count = sizeof(ZOOM_FACTOR_PRESETS) / sizeof(float);
|
||||
zoom_factor = CLAMP(p_zoom_factor, ZOOM_FACTOR_PRESETS[0], ZOOM_FACTOR_PRESETS[preset_count - 1]);
|
||||
zoom_factor = CLAMP(p_zoom_factor, 0.25f, 3.0f);
|
||||
int neutral_font_size = int(EDITOR_GET("interface/editor/code_font_size")) * EDSCALE;
|
||||
int new_font_size = Math::round(zoom_factor * neutral_font_size);
|
||||
|
||||
|
|
@ -1712,6 +1798,7 @@ void CodeTextEditor::_bind_methods() {
|
|||
ADD_SIGNAL(MethodInfo("load_theme_settings"));
|
||||
ADD_SIGNAL(MethodInfo("show_errors_panel"));
|
||||
ADD_SIGNAL(MethodInfo("show_warnings_panel"));
|
||||
ADD_SIGNAL(MethodInfo("navigation_preview_ended"));
|
||||
ADD_SIGNAL(MethodInfo("zoomed", PropertyInfo(Variant::FLOAT, "p_zoom_factor")));
|
||||
}
|
||||
|
||||
|
|
@ -1720,24 +1807,26 @@ 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_button_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()));
|
||||
}
|
||||
|
||||
CodeTextEditor::CodeTextEditor() {
|
||||
code_complete_func = nullptr;
|
||||
ED_SHORTCUT("script_editor/zoom_in", TTR("Zoom In"), KeyModifierMask::CMD_OR_CTRL | Key::EQUAL);
|
||||
ED_SHORTCUT("script_editor/zoom_out", TTR("Zoom Out"), KeyModifierMask::CMD_OR_CTRL | Key::MINUS);
|
||||
ED_SHORTCUT_ARRAY("script_editor/reset_zoom", TTR("Reset Zoom"),
|
||||
ED_SHORTCUT("script_editor/zoom_in", TTRC("Zoom In"), KeyModifierMask::CMD_OR_CTRL | Key::EQUAL);
|
||||
ED_SHORTCUT("script_editor/zoom_out", TTRC("Zoom Out"), KeyModifierMask::CMD_OR_CTRL | Key::MINUS);
|
||||
ED_SHORTCUT_ARRAY("script_editor/reset_zoom", TTRC("Reset Zoom"),
|
||||
{ int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KEY_0), int32_t(KeyModifierMask::CMD_OR_CTRL | Key::KP_0) });
|
||||
|
||||
text_editor = memnew(CodeEdit);
|
||||
|
|
@ -1755,7 +1844,6 @@ CodeTextEditor::CodeTextEditor() {
|
|||
add_child(status_bar);
|
||||
status_bar->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
status_bar->set_custom_minimum_size(Size2(0, 24 * EDSCALE)); // Adjust for the height of the warning icon.
|
||||
|
||||
idle = memnew(Timer);
|
||||
add_child(idle);
|
||||
idle->set_one_shot(true);
|
||||
|
|
@ -1796,7 +1884,6 @@ CodeTextEditor::CodeTextEditor() {
|
|||
error_button->set_default_cursor_shape(CURSOR_POINTING_HAND);
|
||||
error_button->connect(SceneStringName(pressed), callable_mp(this, &CodeTextEditor::_error_button_pressed));
|
||||
error_button->set_tooltip_text(TTR("Errors"));
|
||||
set_error_count(0);
|
||||
|
||||
// Warnings
|
||||
warning_button = memnew(Button);
|
||||
|
|
@ -1806,7 +1893,6 @@ CodeTextEditor::CodeTextEditor() {
|
|||
warning_button->set_default_cursor_shape(CURSOR_POINTING_HAND);
|
||||
warning_button->connect(SceneStringName(pressed), callable_mp(this, &CodeTextEditor::_warning_button_pressed));
|
||||
warning_button->set_tooltip_text(TTR("Warnings"));
|
||||
set_warning_count(0);
|
||||
|
||||
status_bar->add_child(memnew(VSeparator));
|
||||
|
||||
|
|
@ -1815,7 +1901,10 @@ CodeTextEditor::CodeTextEditor() {
|
|||
status_bar->add_child(zoom_button);
|
||||
zoom_button->set_flat(true);
|
||||
zoom_button->set_v_size_flags(SIZE_EXPAND | SIZE_SHRINK_CENTER);
|
||||
zoom_button->set_tooltip_text(TTR("Zoom factor"));
|
||||
zoom_button->set_tooltip_text(
|
||||
TTR("Zoom factor") + "\n" +
|
||||
// TRANSLATORS: The placeholders are keyboard shortcuts. The first one is in the form of "Ctrl+"/"Cmd+".
|
||||
vformat(TTR("%sMouse wheel, %s/%s: Finetune\n%s: Reset"), keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL), ED_GET_SHORTCUT("script_editor/zoom_in")->get_as_text(), ED_GET_SHORTCUT("script_editor/zoom_out")->get_as_text(), ED_GET_SHORTCUT("script_editor/reset_zoom")->get_as_text()));
|
||||
zoom_button->set_text("100 %");
|
||||
|
||||
PopupMenu *zoom_menu = zoom_button->get_popup();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue