summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-12-19 12:19:29 +0100
committerGitHub <noreply@github.com>2019-12-19 12:19:29 +0100
commit8189f23e8c4b806c4e244d0fcce7cb06daa79318 (patch)
tree43da79d63847a04d88db4bb29052be500cd9f9d7 /editor/plugins
parent481eb63a155ba689a86b1649ffdc909aa9547b13 (diff)
parentc89df816c1f1e2c1c43776be60e5cf78ad452c36 (diff)
Merge pull request #34437 from Chaosus/fix_toggle_scripts4
Fix ScriptTextEditor encapsulation
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/script_editor_plugin.cpp14
-rw-r--r--editor/plugins/script_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp6
-rw-r--r--editor/plugins/script_text_editor.h4
4 files changed, 14 insertions, 12 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 54b9cf0630..3d814878a3 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -987,11 +987,8 @@ Array ScriptEditor::_get_open_scripts() const {
return ret;
}
-bool ScriptEditor::toggle_scripts_panel(CodeTextEditor *p_editor) {
+bool ScriptEditor::toggle_scripts_panel() {
list_split->set_visible(!list_split->is_visible());
- if (p_editor) {
- p_editor->update_toggle_scripts_button();
- }
return list_split->is_visible();
}
@@ -1141,14 +1138,13 @@ void ScriptEditor::_menu_option(int p_option) {
} break;
case TOGGLE_SCRIPTS_PANEL: {
if (current) {
- CodeTextEditor *code_editor = NULL;
- ScriptTextEditor *editor = dynamic_cast<ScriptTextEditor *>(current);
+ ScriptTextEditor *editor = Object::cast_to<ScriptTextEditor>(current);
+ toggle_scripts_panel();
if (editor) {
- code_editor = editor->code_editor;
+ editor->update_toggle_scripts_button();
}
- toggle_scripts_panel(code_editor);
} else {
- toggle_scripts_panel(NULL);
+ toggle_scripts_panel();
}
}
}
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index e40d596be7..e2fd67676b 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -419,7 +419,7 @@ protected:
public:
static ScriptEditor *get_singleton() { return script_editor; }
- bool toggle_scripts_panel(CodeTextEditor *p_editor);
+ bool toggle_scripts_panel();
bool is_scripts_panel_toggled();
void ensure_focus_current();
void apply_scripts() const;
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 9bda0f50e4..ec1cda5287 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -966,6 +966,12 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c
}
}
+void ScriptTextEditor::update_toggle_scripts_button() {
+ if (code_editor != NULL) {
+ code_editor->update_toggle_scripts_button();
+ }
+}
+
void ScriptTextEditor::_update_connected_methods() {
TextEdit *text_edit = code_editor->get_text_edit();
text_edit->clear_info_icons();
diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h
index 82d365fcaa..ac29e90c02 100644
--- a/editor/plugins/script_text_editor.h
+++ b/editor/plugins/script_text_editor.h
@@ -55,6 +55,7 @@ class ScriptTextEditor : public ScriptEditorBase {
GDCLASS(ScriptTextEditor, ScriptEditorBase);
+ CodeTextEditor *code_editor;
RichTextLabel *warnings_panel;
Ref<Script> script;
@@ -186,12 +187,11 @@ protected:
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
public:
- CodeTextEditor *code_editor;
-
void _update_connected_methods();
virtual void add_syntax_highlighter(SyntaxHighlighter *p_highlighter);
virtual void set_syntax_highlighter(SyntaxHighlighter *p_highlighter);
+ void update_toggle_scripts_button();
virtual void apply_code();
virtual RES get_edited_resource() const;