summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorUmang Kalra <umangkalra10@gmail.com>2021-08-11 00:44:19 +0530
committerUmang Kalra <umangkalra10@gmail.com>2021-08-11 00:44:28 +0530
commit12fc3f1eefbe43a17e88f43f805e3c118459b7a8 (patch)
treead6c13ec87585364225479ed61fc5c00c23f65b1 /editor
parentda339f8ffcf4c33bb44129d718c0adde910e391d (diff)
Automatic arrangement of nodes in VisualScript/VisualShaders editors
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
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_themes.cpp1
-rw-r--r--editor/icons/GridLayout.svg1
2 files changed, 2 insertions, 0 deletions
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<Theme> create_editor_theme(const Ref<Theme> 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 @@
+<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m14 2.1992188v2.6152343l-2.625 1.3125v-2.6152343zm-12 4.0644531 2.625 1.3125v2.5507811l-2.625-1.3124999zm12 0v2.5507812l-2.625 1.3124999v-2.5507811zm-8 1.4550781h4v2.640625h-4zm-4 2.560547 2.625 1.3125v2.521484l-2.625-1.3125zm12 0v2.521484l-2.625 1.3125v-2.521484zm-8 1.455078h4v2.640625h-4zm1.7014535-8.109375h2.2985465v2.734375h-4.15625s-.7487346.647119-.8746377.640625c-.1310411-.0067594-1.5097373-1.4558594-1.5097373-1.4558594l-1.459375-.7296875v-2.6152343l.068419.034223s.026411-.4573464.062111-.6760553c.0346282-.2121439.1970747-.59225724.1970747-.59225724l-1.0483078-.52372301c-.0795772-.04012218-.1668141-.06276382-.2558594-.06640625-.35427845-.01325803-.64865004.27047362-.6484375.625v12c.00021484.236623.13402736.45284.34570312.558594l3.99999998 2c.086686.043505.1823067.06624.2792969.066406h6c.09699-.000166.192611-.0229.279297-.06641l4-2c.211676-.10575.345488-.321967.345703-.55859v-12c-.000468-.46423753-.488958-.76598317-.904297-.55859375l-3.869141 1.93359375h-2.9709527s.033448.4166167.015891.625c-.029188.3464401-.1950466.625-.1950468.625z" fill="#b05b5b"/><path d="m5 6s-2.21875-2.1616704-2.21875-3.2425057c0-1.0808352 0-2.6072392 2.21875-2.6072392s2.21875 1.526404 2.21875 2.6072392c0 1.0808353-2.21875 3.2425057-2.21875 3.2425057z" fill="#fff" fill-opacity=".68627"/></svg>