diff options
author | Andreas Haas <Hinsbart@users.noreply.github.com> | 2017-10-03 19:56:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-03 19:56:14 +0200 |
commit | a848fa6cdeb00f0c40f259cde2d59112272e3c51 (patch) | |
tree | 1c6246c425eb58f900bf713256bf37e6de606e13 /editor | |
parent | d08f7ee7bf9b8f207739b4916b1c7ba7028eaecc (diff) | |
parent | bb69855f1ac32d657e53c388d12b37464f4efa7c (diff) |
Merge pull request #11789 from djrm/pr_visual_improvements
Added correct initialization for script editor theme.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_themes.cpp | 44 | ||||
-rw-r--r-- | editor/icons/icon_GUI_tree_updown.svg | 5 | ||||
-rw-r--r-- | editor/icons/icon_mini_color.svg | 6 | ||||
-rw-r--r-- | editor/icons/icon_mini_image.svg | 5 | ||||
-rw-r--r-- | editor/icons/icon_mini_input.svg | 5 | ||||
-rw-r--r-- | editor/plugins/script_editor_plugin.cpp | 3 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.cpp | 40 | ||||
-rw-r--r-- | editor/plugins/script_text_editor.h | 12 |
8 files changed, 86 insertions, 34 deletions
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index a2e6df4e41..0436ac78df 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -146,6 +146,25 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme = ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#84c2ff", "#5caeff"); // selection (blue) ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea686c", "#e3383d"); // key xform (red) + + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#61daf4", "#27ccf0"); // VS float + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6ba7ec", "#4690e7"); // VS string + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#bd91f1", "#ad76ee"); // VS vector2 + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f191a5", "#ee758e"); // VS rect + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e286f0", "#dc6aed"); // VS vector3 + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c4ec69", "#96ce1a"); // VS transform2D + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f77070", "#f77070"); // VS plane + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ec69a3", "#ec69a3"); // VS quat + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ee7991", "#ee7991"); // VS aabb + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e3ec69", "#b2bb19"); // VS basis + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f6a86e", "#f49047"); // VS transform + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#6993ec", "#6993ec"); // VS path + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ec9a", "#2ce573"); // VS rid + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#79f3e8", "#12d5c3"); // VS object + ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#77edb1", "#57e99f"); // VS dict } // these ones should be converted even if we are using a dark theme @@ -474,7 +493,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("MenuPanel", "EditorStyles", style_menu); // Script Editor - theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(4, 0, 4, 4)); + theme->set_stylebox("ScriptEditorPanel", "EditorStyles", make_empty_stylebox(default_margin_size, 0, default_margin_size, default_margin_size)); theme->set_stylebox("ScriptEditor", "EditorStyles", make_empty_stylebox(0, 0, 0, 0)); // Play button group @@ -545,7 +564,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "OptionButton", font_color_disabled); theme->set_color("icon_color_hover", "OptionButton", font_color_hl); theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons")); - theme->set_constant("arrow_margin", "OptionButton", 4 * EDSCALE); + theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE); theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton @@ -597,6 +616,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("unchecked", "Tree", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("arrow", "Tree", theme->get_icon("GuiTreeArrowDown", "EditorIcons")); theme->set_icon("arrow_collapsed", "Tree", theme->get_icon("GuiTreeArrowRight", "EditorIcons")); + theme->set_icon("updown", "Tree", theme->get_icon("GuiTreeUpdown", "EditorIcons")); theme->set_icon("select_arrow", "Tree", theme->get_icon("GuiDropdown", "EditorIcons")); theme->set_icon("select_option", "Tree", theme->get_icon("GuiTreeOption", "EditorIcons")); theme->set_stylebox("bg_focus", "Tree", style_focus); @@ -672,8 +692,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color", "ItemList", font_color); theme->set_color("font_color_selected", "ItemList", mono_color); theme->set_color("guide_color", "ItemList", guide_color); - theme->set_constant("vseparation", "ItemList", 2); - theme->set_constant("hseparation", "ItemList", 2); + theme->set_constant("vseparation", "ItemList", 2 * EDSCALE); + theme->set_constant("hseparation", "ItemList", 2 * EDSCALE); theme->set_constant("icon_margin", "ItemList", default_margin_size * EDSCALE); theme->set_constant("line_separation", "ItemList", 2 * EDSCALE); @@ -880,21 +900,23 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // GraphNode + const float mv = dark_theme ? 0.0 : 1.0; + const float mv2 = 1.0 - mv; const int gn_margin_side = 28; - Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(0, 0, 0, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsb = make_flat_stylebox(Color(mv, mv, mv, 0.7), gn_margin_side, 24, gn_margin_side, 5); graphsb->set_border_width_all(border_width); - graphsb->set_border_color_all(Color(1, 1, 1, 0.9)); - Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(0, 0, 0, 0.6), gn_margin_side, 24, gn_margin_side, 5); + graphsb->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); + Ref<StyleBoxFlat> graphsbselected = make_flat_stylebox(Color(mv, mv, mv, 0.9), gn_margin_side, 24, gn_margin_side, 5); graphsbselected->set_border_width_all(border_width); graphsbselected->set_border_color_all(Color(accent_color.r, accent_color.g, accent_color.b, 0.9)); graphsbselected->set_shadow_size(8 * EDSCALE); graphsbselected->set_shadow_color(shadow_color); - Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(0, 0, 0, 0.3), gn_margin_side, 24, gn_margin_side, 5); + Ref<StyleBoxFlat> graphsbcomment = make_flat_stylebox(Color(mv, mv, mv, 0.3), gn_margin_side, 24, gn_margin_side, 5); graphsbcomment->set_border_width_all(border_width); - graphsbcomment->set_border_color_all(Color(1, 1, 1, 0.9)); - Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(0, 0, 0, 0.4), gn_margin_side, 24, gn_margin_side, 5); + graphsbcomment->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); + Ref<StyleBoxFlat> graphsbcommentselected = make_flat_stylebox(Color(mv, mv, mv, 0.4), gn_margin_side, 24, gn_margin_side, 5); graphsbcommentselected->set_border_width_all(border_width); - graphsbcommentselected->set_border_color_all(Color(1, 1, 1, 0.9)); + graphsbcommentselected->set_border_color_all(Color(mv2, mv2, mv2, 0.9)); Ref<StyleBoxFlat> graphsbbreakpoint = graphsbselected->duplicate(); graphsbbreakpoint->set_draw_center(false); graphsbbreakpoint->set_border_color_all(warning_color); diff --git a/editor/icons/icon_GUI_tree_updown.svg b/editor/icons/icon_GUI_tree_updown.svg new file mode 100644 index 0000000000..cdcd6c2441 --- /dev/null +++ b/editor/icons/icon_GUI_tree_updown.svg @@ -0,0 +1,5 @@ +<svg width="14" height="14" version="1.1" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1038.4)"> +<path transform="translate(0 1038.4)" d="m6.9844 1.002a1.0001 1.0001 0 0 0 -0.69141 0.29102l-3 3a1 1 0 0 0 0 1.4141 1 1 0 0 0 1.4141 0l2.293-2.293 2.293 2.293a1 1 0 0 0 1.4141 0 1 1 0 0 0 0 -1.4141l-3-3a1.0001 1.0001 0 0 0 -0.72266 -0.29102zm3 6.998a1 1 0 0 0 -0.69141 0.29297l-2.293 2.293-2.293-2.293a1 1 0 0 0 -0.7207 -0.29102 1 1 0 0 0 -0.69336 0.29102 1 1 0 0 0 0 1.4141l3 3a1.0001 1.0001 0 0 0 1.4141 0l3-3a1 1 0 0 0 0 -1.4141 1 1 0 0 0 -0.72266 -0.29297z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#fff" fill-opacity=".58824" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="filter-blend-mode:normal;filter-gaussianBlur-deviation:0;font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +</g> +</svg> diff --git a/editor/icons/icon_mini_color.svg b/editor/icons/icon_mini_color.svg index b70015a05d..623f922158 100644 --- a/editor/icons/icon_mini_color.svg +++ b/editor/icons/icon_mini_color.svg @@ -1,7 +1,7 @@ <svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> <g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m4 4a3 3 0 0 0 -3 3 3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1h1v-2h-1z" fill="#ff7070"/> -<path transform="translate(0 1040.4)" d="m14 4a3 3 0 0 0 -3 3v3h2v-3a1 1 0 0 1 1 -1h1v-2h-1z" fill="#70bfff"/> -<path transform="translate(0 1040.4)" d="m6 2v5a3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1v-5h-2z" fill="#7aff70"/> +<path transform="translate(0 1040.4)" d="m4 4a3 3 0 0 0 -3 3 3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1h1v-2h-1z" fill="#ff8484"/> +<path transform="translate(0 1040.4)" d="m14 4a3 3 0 0 0 -3 3v3h2v-3a1 1 0 0 1 1 -1h1v-2h-1z" fill="#84c2ff"/> +<path transform="translate(0 1040.4)" d="m6 2v5a3 3 0 0 0 3 3h1v-2h-1a1 1 0 0 1 -1 -1v-5h-2z" fill="#84ffb1"/> </g> </svg> diff --git a/editor/icons/icon_mini_image.svg b/editor/icons/icon_mini_image.svg deleted file mode 100644 index 735cb563cb..0000000000 --- a/editor/icons/icon_mini_image.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m0 1v2h2v-2h-2zm3 2v6h2v-4a1 1 0 0 1 1 1v3h2v-3-1a1 1 0 0 1 1 1v3h2v-3a3 3 0 0 0 -3 -3h-2v0.17578a3 3 0 0 0 -1 -0.17578h-2zm8 3a3 3 0 0 0 3 3 1 1 0 0 1 -1 1h-1v2h1a3 3 0 0 0 3 -3v-6h-2a3 3 0 0 0 -3 3zm-11-1v4h2v-4h-2zm14 0v2a1 1 0 0 1 -1 -1 1 1 0 0 1 1 -1z" fill="#93f1b9"/> -</g> -</svg> diff --git a/editor/icons/icon_mini_input.svg b/editor/icons/icon_mini_input.svg deleted file mode 100644 index 92cf763cf8..0000000000 --- a/editor/icons/icon_mini_input.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="16" height="12" version="1.1" viewBox="0 0 16 12" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1040.4)"> -<path transform="translate(0 1040.4)" d="m0 2v2h2v-2h-2zm13 0v5a3 3 0 0 0 3 3v-2a1 1 0 0 1 -1 -1v-1h1v-2h-1v-2h-2zm0 5a3 3 0 0 0 -3 -3h-2v3a3 3 0 0 0 -3 -3h-2v6h2v-4a1 1 0 0 1 1 1v3h2v2h2v-2a3 3 0 0 0 3 -3zm-13-1v4h2v-4h-2zm10 0a1 1 0 0 1 1 1 1 1 0 0 1 -1 1v-2z" fill="#adf18f"/> -</g> -</svg> diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 9af5885a17..5e66488afb 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -1683,9 +1683,8 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool } ERR_FAIL_COND_V(!se, false); - // load script before adding as child else editor will crash at theme loading - se->set_edited_script(p_script); tab_container->add_child(se); + se->set_edited_script(p_script); se->set_tooltip_request_func("_get_debug_tooltip", this); if (se->get_edit_menu()) { se->get_edit_menu()->hide(); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index b66e9598f9..a24856dad7 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -168,14 +168,34 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_constant_override("line_spacing", EDITOR_DEF("text_editor/theme/line_spacing", 4)); + colors_cache.symbol_color = symbol_color; + colors_cache.keyword_color = keyword_color; + colors_cache.basetype_color = basetype_color; + colors_cache.type_color = type_color; + colors_cache.comment_color = comment_color; + colors_cache.string_color = string_color; + + theme_loaded = true; + if (!script.is_null()) + _set_theme_for_script(); +} + +void ScriptTextEditor::_set_theme_for_script() { + + if (!theme_loaded) + return; + + TextEdit *text_edit = code_editor->get_text_edit(); + List<String> keywords; script->get_language()->get_reserved_words(&keywords); for (List<String>::Element *E = keywords.front(); E; E = E->next()) { - text_edit->add_keyword_color(E->get(), keyword_color); + text_edit->add_keyword_color(E->get(), colors_cache.keyword_color); } //colorize core types + const Color basetype_color = colors_cache.basetype_color; text_edit->add_keyword_color("String", basetype_color); text_edit->add_keyword_color("Vector2", basetype_color); text_edit->add_keyword_color("Rect2", basetype_color); @@ -210,7 +230,7 @@ void ScriptTextEditor::_load_theme_settings() { if (n.begins_with("_")) n = n.substr(1, n.length()); - text_edit->add_keyword_color(n, type_color); + text_edit->add_keyword_color(n, colors_cache.type_color); } //colorize comments @@ -223,7 +243,7 @@ void ScriptTextEditor::_load_theme_settings() { String beg = comment.get_slice(" ", 0); String end = comment.get_slice_count(" ") > 1 ? comment.get_slice(" ", 1) : String(); - text_edit->add_color_region(beg, end, comment_color, end == ""); + text_edit->add_color_region(beg, end, colors_cache.comment_color, end == ""); } //colorize strings @@ -235,7 +255,7 @@ void ScriptTextEditor::_load_theme_settings() { String string = E->get(); String beg = string.get_slice(" ", 0); String end = string.get_slice_count(" ") > 1 ? string.get_slice(" ", 1) : String(); - text_edit->add_color_region(beg, end, string_color, end == ""); + text_edit->add_color_region(beg, end, colors_cache.string_color, end == ""); } } @@ -263,10 +283,10 @@ void ScriptTextEditor::reload_text() { void ScriptTextEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_READY) { - - //emit_signal("name_changed"); - _load_theme_settings(); + switch (p_what) { + case NOTIFICATION_READY: + _load_theme_settings(); + break; } } @@ -556,6 +576,8 @@ void ScriptTextEditor::set_edited_script(const Ref<Script> &p_script) { emit_signal("name_changed"); code_editor->update_line_and_column(); + + _set_theme_for_script(); } void ScriptTextEditor::_validate_script() { @@ -1452,6 +1474,8 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { ScriptTextEditor::ScriptTextEditor() { + theme_loaded = false; + code_editor = memnew(CodeTextEditor); add_child(code_editor); code_editor->add_constant_override("separation", 0); diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index f8b7470ec8..83f3ea57c0 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -57,6 +57,17 @@ class ScriptTextEditor : public ScriptEditorBase { int color_line; String color_args; + struct ColorsCache { + Color symbol_color; + Color keyword_color; + Color basetype_color; + Color type_color; + Color comment_color; + Color string_color; + } colors_cache; + + bool theme_loaded; + enum { EDIT_UNDO, EDIT_REDO, @@ -101,6 +112,7 @@ protected: void _validate_script(); void _code_complete_script(const String &p_code, List<String> *r_options, bool &r_force); void _load_theme_settings(); + void _set_theme_for_script(); void _notification(int p_what); static void _bind_methods(); |