Skip to content

Commit

Permalink
Merge pull request godotengine#44470 from pycbouh/graph-minimap-3.2
Browse files Browse the repository at this point in the history
[3.2] Add a minimap to the GraphEdit
  • Loading branch information
akien-mga committed Dec 17, 2020
2 parents 65c1db3 + 816fef2 commit 68013d2
Show file tree
Hide file tree
Showing 8 changed files with 511 additions and 10 deletions.
9 changes: 9 additions & 0 deletions doc/classes/GraphEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,15 @@
</methods>
<members>
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" />
<member name="minimap_enabled" type="bool" setter="set_minimap_enabled" getter="is_minimap_enabled" default="true">
If [code]true[/code], the minimap is visible.
</member>
<member name="minimap_opacity" type="float" setter="set_minimap_opacity" getter="get_minimap_opacity" default="0.65">
The opacity of the minimap rectangle.
</member>
<member name="minimap_size" type="Vector2" setter="set_minimap_size" getter="get_minimap_size" default="Vector2(240, 160)">
The size of the minimap rectangle. The map itself is based on the size of the grid area and is scaled to fit this rectangle.
</member>
<member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" />
<member name="right_disconnects" type="bool" setter="set_right_disconnects" getter="is_right_disconnects_enabled" default="false">
If [code]true[/code], enables disconnection of existing connections in the GraphEdit by dragging the right end.
Expand Down
43 changes: 42 additions & 1 deletion editor/editor_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,25 @@ static Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1,
return style;
}

static Ref<Texture> flip_icon(Ref<Texture> p_texture, bool p_flip_y = false, bool p_flip_x = false) {
if (!p_flip_y && !p_flip_x) {
return p_texture;
}

Ref<ImageTexture> texture(memnew(ImageTexture));
Ref<Image> img = p_texture->get_data();

if (p_flip_y) {
img->flip_y();
}
if (p_flip_x) {
img->flip_x();
}

texture->create_from_image(img);
return texture;
}

#ifdef SVG_ENABLED
static Ref<ImageTexture> editor_generate_icon(int p_index, bool p_convert_color, float p_scale = EDSCALE, bool p_force_filter = false) {

Expand Down Expand Up @@ -1052,11 +1071,33 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons"));
theme->set_icon("reset", "GraphEdit", theme->get_icon("ZoomReset", "EditorIcons"));
theme->set_icon("snap", "GraphEdit", theme->get_icon("SnapGrid", "EditorIcons"));
theme->set_icon("minimap", "GraphEdit", theme->get_icon("GridMinimap", "EditorIcons"));
theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE);
theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE);

// GraphNode
// GraphEditMinimap
theme->set_stylebox("bg", "GraphEditMinimap", make_flat_stylebox(dark_color_1, 0, 0, 0, 0));
Ref<StyleBoxFlat> style_minimap_camera;
Ref<StyleBoxFlat> style_minimap_node;
if (dark_theme) {
style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0);
style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45));
style_minimap_node = make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0);
} else {
style_minimap_camera = make_flat_stylebox(Color(0.38, 0.38, 0.38, 0.2), 0, 0, 0, 0);
style_minimap_camera->set_border_color(Color(0.38, 0.38, 0.38, 0.45));
style_minimap_node = make_flat_stylebox(Color(0, 0, 0), 0, 0, 0, 0);
}
style_minimap_camera->set_border_width_all(1);
style_minimap_node->set_corner_radius_all(1);
theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);

Ref<Texture> 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));

// GraphNode
const float mv = dark_theme ? 0.0 : 1.0;
const float mv2 = 1.0 - mv;
const int gn_margin_side = 28;
Expand Down
1 change: 1 addition & 0 deletions editor/icons/icon_grid_minimap.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 68013d2

Please sign in to comment.