diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-25 20:32:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-25 20:32:46 +0100 |
commit | d7aea6ff6c54466dba51b75de5942154fbffe75d (patch) | |
tree | 007454c2ce3140f711a17a38ea7a479c0412bc90 | |
parent | f7b814f9438984221bf0644f25c4c87447ba033e (diff) | |
parent | 9d9d0f0bc995a4db9ee1e823380076bf2aca70d8 (diff) |
Merge pull request #45447 from pycbouh/graphedit-minimap-active-invisible
Fix minimap capturing events and improve its theme and editor settings
-rw-r--r-- | editor/editor_settings.cpp | 4 | ||||
-rw-r--r-- | editor/editor_themes.cpp | 19 | ||||
-rw-r--r-- | editor/plugins/animation_blend_tree_editor_plugin.cpp | 5 | ||||
-rw-r--r-- | editor/plugins/visual_shader_editor_plugin.cpp | 5 | ||||
-rw-r--r-- | modules/visual_script/visual_script_editor.cpp | 6 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 6 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 1 |
7 files changed, 41 insertions, 5 deletions
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 3eee7b2bfb..7a602912c9 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -659,6 +659,10 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("editors/animation/onion_layers_past_color", Color(1, 0, 0)); _initial_set("editors/animation/onion_layers_future_color", Color(0, 1, 0)); + // Visual editors + _initial_set("editors/visual_editors/minimap_opacity", 0.85); + hints["editors/visual_editors/minimap_opacity"] = PropertyInfo(Variant::FLOAT, "editors/visual_editors/minimap_opacity", PROPERTY_HINT_RANGE, "0.0,1.0,0.01", PROPERTY_USAGE_DEFAULT); + /* Run */ // Window placement diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 054ada1e8d..37d32431cc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -92,6 +92,7 @@ static Ref<Texture2D> flip_icon(Ref<Texture2D> p_texture, bool p_flip_y = false, Ref<ImageTexture> texture(memnew(ImageTexture)); Ref<Image> img = p_texture->get_data(); + img = img->duplicate(); if (p_flip_y) { img->flip_y(); @@ -1098,7 +1099,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE); // GraphEditMinimap - theme->set_stylebox("bg", "GraphEditMinimap", make_flat_stylebox(dark_color_1, 0, 0, 0, 0)); + Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(dark_color_1, 0, 0, 0, 0); + style_minimap_bg->set_border_color(dark_color_3); + style_minimap_bg->set_border_width_all(1); + theme->set_stylebox("bg", "GraphEditMinimap", style_minimap_bg); + Ref<StyleBoxFlat> style_minimap_camera; Ref<StyleBoxFlat> style_minimap_node; if (dark_theme) { @@ -1115,9 +1120,15 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera); theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node); - Ref<Texture2D> resizer_icon = theme->get_icon("GuiResizer", "EditorIcons"); - theme->set_icon("resizer", "GraphEditMinimap", flip_icon(resizer_icon, true, true)); - theme->set_color("resizer_color", "GraphEditMinimap", Color(1, 1, 1, 0.65)); + Ref<Texture2D> minimap_resizer_icon = theme->get_icon("GuiResizer", "EditorIcons"); + Color minimap_resizer_color; + if (dark_theme) { + minimap_resizer_color = Color(1, 1, 1, 0.65); + } else { + minimap_resizer_color = Color(0, 0, 0, 0.65); + } + theme->set_icon("resizer", "GraphEditMinimap", flip_icon(minimap_resizer_icon, true, true)); + theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color); // GraphNode const float mv = dark_theme ? 0.0 : 1.0; diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp index fbfcac3d22..e7e069e8b6 100644 --- a/editor/plugins/animation_blend_tree_editor_plugin.cpp +++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp @@ -255,6 +255,9 @@ void AnimationNodeBlendTreeEditor::_update_graph() { graph->connect_node(from, 0, to, to_idx); } + + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); } void AnimationNodeBlendTreeEditor::_file_opened(const String &p_file) { @@ -888,6 +891,8 @@ AnimationNodeBlendTreeEditor::AnimationNodeBlendTreeEditor() { graph->connect("scroll_offset_changed", callable_mp(this, &AnimationNodeBlendTreeEditor::_scroll_changed)); graph->connect("delete_nodes_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_delete_nodes_request)); graph->connect("popup_request", callable_mp(this, &AnimationNodeBlendTreeEditor::_popup_request)); + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); VSeparator *vs = memnew(VSeparator); graph->get_zoom_hbox()->add_child(vs); diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index 443e867a9f..4c3964289f 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -1282,6 +1282,9 @@ void VisualShaderEditor::_update_graph() { graph->connect_node(itos(from), from_idx, itos(to), to_idx); } + + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); } VisualShader::Type VisualShaderEditor::get_current_shader_type() const { @@ -3161,6 +3164,8 @@ VisualShaderEditor::VisualShaderEditor() { graph->set_h_size_flags(SIZE_EXPAND_FILL); add_child(graph); graph->set_drag_forwarding(this); + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_SCALAR_INT); graph->add_valid_right_disconnect_type(VisualShaderNode::PORT_TYPE_BOOLEAN); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 1e82259e59..78e4a7f113 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -981,6 +981,10 @@ void VisualScriptEditor::_update_graph(int p_only_id) { } _update_graph_connections(); + + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); + // Use default_func instead of default_func for now I think that should be good stop gap solution to ensure not breaking anything. graph->call_deferred("set_scroll_ofs", script->get_scroll() * EDSCALE); updating_graph = false; @@ -4326,6 +4330,8 @@ VisualScriptEditor::VisualScriptEditor() { graph->connect("duplicate_nodes_request", callable_mp(this, &VisualScriptEditor::_on_nodes_duplicate)); graph->connect("gui_input", callable_mp(this, &VisualScriptEditor::_graph_gui_input)); graph->set_drag_forwarding(this); + float graph_minimap_opacity = EditorSettings::get_singleton()->get("editors/visual_editors/minimap_opacity"); + graph->set_minimap_opacity(graph_minimap_opacity); graph->hide(); graph->connect("scroll_offset_changed", callable_mp(this, &VisualScriptEditor::_graph_ofs_changed)); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 6662992d46..bc87aabb2c 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -154,6 +154,10 @@ Vector2 GraphEditMinimap::_convert_to_graph_position(const Vector2 &p_position) } void GraphEditMinimap::_gui_input(const Ref<InputEvent> &p_ev) { + if (!ge->is_minimap_enabled()) { + return; + } + Ref<InputEventMouseButton> mb = p_ev; Ref<InputEventMouseMotion> mm = p_ev; @@ -1754,7 +1758,7 @@ GraphEdit::GraphEdit() { top_layer->add_child(minimap); minimap->set_name("_minimap"); minimap->set_modulate(Color(1, 1, 1, minimap_opacity)); - minimap->set_mouse_filter(MOUSE_FILTER_STOP); + minimap->set_mouse_filter(MOUSE_FILTER_PASS); minimap->set_custom_minimum_size(Vector2(50, 50)); minimap->set_size(minimap_size); minimap->set_anchors_preset(Control::PRESET_BOTTOM_RIGHT); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 982239fe4e..5878467aaa 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -115,6 +115,7 @@ static Ref<Texture2D> flip_icon(Ref<Texture2D> p_texture, bool p_flip_y = false, Ref<ImageTexture> texture(memnew(ImageTexture)); Ref<Image> img = p_texture->get_data(); + img = img->duplicate(); if (p_flip_y) { img->flip_y(); |