summaryrefslogtreecommitdiff
path: root/editor/code_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r--editor/code_editor.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index db44edcfcb..e5b4cbdda1 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -1508,6 +1508,10 @@ void CodeTextEditor::_set_show_warnings_panel(bool p_show) {
emit_signal("show_warnings_panel", p_show);
}
+void CodeTextEditor::_toggle_scripts_pressed() {
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->toggle_scripts_panel() ? get_icon("Back", "EditorIcons") : get_icon("Forward", "EditorIcons"));
+}
+
void CodeTextEditor::_error_pressed(const Ref<InputEvent> &p_event) {
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
@@ -1523,6 +1527,9 @@ void CodeTextEditor::_notification(int p_what) {
emit_signal("load_theme_settings");
} break;
case NOTIFICATION_THEME_CHANGED: {
+ if (toggle_scripts_button->is_visible()) {
+ update_toggle_scripts_button();
+ }
_update_font();
} break;
case NOTIFICATION_ENTER_TREE: {
@@ -1530,6 +1537,9 @@ void CodeTextEditor::_notification(int p_what) {
add_constant_override("separation", 4 * EDSCALE);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
+ if (toggle_scripts_button->is_visible()) {
+ update_toggle_scripts_button();
+ }
set_process_input(is_visible_in_tree());
} break;
default:
@@ -1563,6 +1573,7 @@ void CodeTextEditor::goto_next_bookmark() {
if (line >= bmarks[bmarks.size() - 1]) {
text_editor->unfold_line(bmarks[0]);
text_editor->cursor_set_line(bmarks[0]);
+ text_editor->center_viewport_to_cursor();
} else {
for (List<int>::Element *E = bmarks.front(); E; E = E->next()) {
int bline = E->get();
@@ -1588,6 +1599,7 @@ void CodeTextEditor::goto_prev_bookmark() {
if (line <= bmarks[0]) {
text_editor->unfold_line(bmarks[bmarks.size() - 1]);
text_editor->cursor_set_line(bmarks[bmarks.size() - 1]);
+ text_editor->center_viewport_to_cursor();
} else {
for (List<int>::Element *E = bmarks.back(); E; E = E->prev()) {
int bline = E->get();
@@ -1623,6 +1635,7 @@ void CodeTextEditor::_bind_methods() {
ClassDB::bind_method("_complete_request", &CodeTextEditor::_complete_request);
ClassDB::bind_method("_font_resize_timeout", &CodeTextEditor::_font_resize_timeout);
ClassDB::bind_method("_error_pressed", &CodeTextEditor::_error_pressed);
+ ClassDB::bind_method("_toggle_scripts_pressed", &CodeTextEditor::_toggle_scripts_pressed);
ClassDB::bind_method("_warning_button_pressed", &CodeTextEditor::_warning_button_pressed);
ClassDB::bind_method("_warning_label_gui_input", &CodeTextEditor::_warning_label_gui_input);
@@ -1637,6 +1650,15 @@ void CodeTextEditor::set_code_complete_func(CodeTextEditorCodeCompleteFunc p_cod
code_complete_ud = p_ud;
}
+void CodeTextEditor::show_toggle_scripts_button() {
+ toggle_scripts_button->show();
+}
+
+void CodeTextEditor::update_toggle_scripts_button() {
+ toggle_scripts_button->set_icon(ScriptEditor::get_singleton()->is_scripts_panel_toggled() ? get_icon("Back", "EditorIcons") : get_icon("Forward", "EditorIcons"));
+ toggle_scripts_button->set_tooltip(TTR("Toggle Scripts Panel") + " (" + ED_GET_SHORTCUT("script_editor/toggle_scripts_panel")->get_as_text() + ")");
+}
+
CodeTextEditor::CodeTextEditor() {
code_complete_func = NULL;
@@ -1678,6 +1700,11 @@ CodeTextEditor::CodeTextEditor() {
error_line = 0;
error_column = 0;
+ toggle_scripts_button = memnew(ToolButton);
+ toggle_scripts_button->connect("pressed", this, "_toggle_scripts_pressed");
+ status_bar->add_child(toggle_scripts_button);
+ toggle_scripts_button->hide();
+
// Error
ScrollContainer *scroll = memnew(ScrollContainer);
scroll->set_h_size_flags(SIZE_EXPAND_FILL);