From 12fc3f1eefbe43a17e88f43f805e3c118459b7a8 Mon Sep 17 00:00:00 2001 From: Umang Kalra Date: Wed, 11 Aug 2021 00:44:19 +0530 Subject: Automatic arrangement of nodes in VisualScript/VisualShaders editors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR and commit adds the functionality to arrange nodes in VisualScript/VisualShader editor. The layout generated by this feature is compact, with minimum crossings between connections & uniform horizontal & vertical gaps between the nodes. This work has been sponsored by GSoC '21. Full list of additions/changes: • Added arrange_nodes() method in GraphEdit module. • This method computes new positions for all the selected nodes by forming blocks and compressing them. The nodes are moved to these new positions. • Adding this method to GraphEdit makes it available for use in VisualScript/VisualShaders editors and its other subclasses. • Button with an icon has been added to call arrange_nodes() in GraphEdit. • This button is inherited by VisualScript/VisualShaders editors to invoke the method. • Undo/redo is functional with this method. • By using signals in arrange_nodes(), position changes are registered in undo/redo stack of the subclass that is using the method. • Metadata of the method has been updated in ClassDB • Method description has been added to class reference of GraphEdit --- editor/editor_themes.cpp | 1 + editor/icons/GridLayout.svg | 1 + 2 files changed, 2 insertions(+) create mode 100644 editor/icons/GridLayout.svg (limited to 'editor') diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 0d714065e3..28bd9c5206 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1232,6 +1232,7 @@ Ref create_editor_theme(const Ref p_theme) { 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_icon("layout", "GraphEdit", theme->get_icon("GridLayout", "EditorIcons")); theme->set_constant("bezier_len_pos", "GraphEdit", 80 * EDSCALE); theme->set_constant("bezier_len_neg", "GraphEdit", 160 * EDSCALE); diff --git a/editor/icons/GridLayout.svg b/editor/icons/GridLayout.svg new file mode 100644 index 0000000000..71ad504477 --- /dev/null +++ b/editor/icons/GridLayout.svg @@ -0,0 +1 @@ + -- cgit v1.2.3