-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GraphEdit/GraphNode refactor [V2] #67152
Conversation
fa0d694
to
6376dcc
Compare
Why did the Linux build fail? |
I support this, and the work was started before the feature freeze. |
I'm super excited about these features. It'll make my development of Choreographer 1000% easier. Great job @Geometror ! Hoping these can get accepted & merged |
I support this as well. |
6376dcc
to
ff67573
Compare
About the GraphFrame behaviour: IMO Blender has this done really nicely where it automatically detects when you put in the nodes inside the frame and resized itself to fit in the node after the drag finishes. The other points like e.g. the minimizing nodes feature would be a nice to have for larger graphs or subgraphs but not sure how much work this would be to implement. Would these changes be compatibility breaking or could they still be implemented when your rework PR is merged? |
c376d1c
to
f5e21fb
Compare
f5e21fb
to
dc9a7a0
Compare
Any news on this? |
I would like this but Godot Engine 4.0 tasks have taken priority. |
This PR, while it has some breaking changes, will be a part of 4.1. We'll see if we can smooth out the experience for existing users, though this node is unlikely to be used in games. It's more of a tool for editor plugins and standalone tools. This is to say that in the worst case scenario, developers should still be capable of updating their tools to the new setup. |
I will chime in (tried using existing GraphEdit/Node for a tool) - this refactor is really needed |
cc4b889
to
e2bc01b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm starting to look at the code, but have a few general notes.
-
GraphFrame is barely usable, and you also mention issues with it in your latest comments. My suggestion is to just drop it for now, remove that feature completely for the initial implementation. Its UX is not there yet, and it distracts you with layering issues. So let's get back to it in a follow-up.
- Some fallback code needs to be added for visual shaders though, so that comments information is preserved, even if you can't see or edit it.
-
I'm concerned about the naming scheme. IMO GraphControl doesn't make sense as the base type for GraphNode, since in Godot's terms Node is more basic than Control. So, I think it would be confusing with the concepts reversed. Perhaps GraphObject or GraphItem would be better as the base type?
-
I'd urge you to not add more features to this PR. As I mentioned in the proposal before, this should be really done in steps. Some things are easy to add alongside the general refactoring, but the more changes this includes, the harder it is to get to a mergeable state and review. I'd like to have the initial refactoring merged within the next two weeks, so we can have it in 4.1.
There are also a couple of review comments. I'll look into the implementation soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This SVG is missing width and height attributes alongside its viewBox.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it, but most of the icons in the default_theme folder don't have these attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should, otherwise they may not be rendered correctly.
ClassDB::bind_method(D_METHOD("get_tint_color"), &GraphFrame::get_tint_color); | ||
|
||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "title"), "set_title", "get_title"); | ||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "title_centered"), "set_title_centered", "is_title_centered"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can move the title string to the base type, because even if some custom node doesn't render the title in the conventional way, or at all, having one is still handy most of the time, so there is little reason for duplication.
title_centered
should be removed, IMO. I'm not sure if there is a demand for it, and since we're refactoring everything, it's better to drop it and reintroduce later if there is an extra need for convenience.
doc/classes/GraphNode.xml
Outdated
@@ -21,145 +21,138 @@ | |||
</method> | |||
<method name="clear_slot"> | |||
<return type="void" /> | |||
<param index="0" name="slot_index" type="int" /> | |||
<param index="0" name="slot_idx" type="int" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO parameters should be named more verbosely, and this was already the case here. Changing it feels like going backwards. The port one renamed below should also be expanded.
Overall you aim to improve the naming and make it more explicit, and here it's the opposite for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of comments on the API surface and on the changes in editor plugins.
doc/classes/GraphEdit.xml
Outdated
</member> | ||
<member name="use_snap" type="bool" setter="set_use_snap" getter="is_using_snap" default="true"> | ||
<member name="use_snap" type="bool" setter="set_use_grid_snap" getter="is_using_grid_snap" default="false"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why rename the methods but not the property? I think that a better name for both would be snapping_enabled
, without any mention of the grid (since it's not related to the visual grid anymore).
// All nodes are closable except the output node. | ||
if (p_id >= 2) { | ||
vsnode->set_closable(true); | ||
node->connect("close_request", callable_mp(editor, &VisualShaderEditor::_delete_node_request).bind(p_type, p_id), CONNECT_DEFERRED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work? You removed the button, and this signal is emitted by GraphControl::_close_requested()
, but I don't see _close_requested
being called anywhere? delete_node_request
is handled on the graph level, so shortcuts should still work. But this seems to be no-op.
@@ -466,19 +488,35 @@ void VisualShaderGraphPlugin::add_node(VisualShader::Type p_type, int p_id, bool | |||
} | |||
|
|||
node->set_position_offset(visual_shader->get_node_position(p_type, p_id)); | |||
node->set_title(vsnode->get_caption()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep the title if you follow the suggestion to put the method onto the base class.
} | ||
node->set_slot(i + port_offset, valid_left, port_left, type_color[port_left], true, VisualShaderNode::PORT_TYPE_SCALAR, vector_expanded_color[0]); | ||
port_offset++; | ||
graph_node->set_slot(idx, valid_left, port_left, type_color[port_left], valid_right, port_right, type_color[port_right]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need a type check here in case it's not GraphNode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more notes from the main classes. So far I've ignored everything related to frames/comments, and I haven't looked through the updated GraphNode.
void GraphControl::_close_requested() { | ||
// Send focus to parent. | ||
get_parent_control()->grab_focus(); | ||
emit_signal(SNAME("close_request")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned before, this doesn't seem to be called anywhere.
@@ -270,78 +273,78 @@ void GraphEdit::_update_scroll_offset() { | |||
set_block_minimum_size_adjust(true); | |||
|
|||
for (int i = 0; i < get_child_count(); i++) { | |||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); | |||
if (!gn) { | |||
GraphControl *graph_node = Object::cast_to<GraphControl>(get_child(i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name is confusing as it refers to a different type.
for (int i = 0; i < get_child_count(); i++) { | ||
GraphNode *gn = Object::cast_to<GraphNode>(get_child(i)); | ||
if (!gn) { | ||
GraphControl *graph_node = Object::cast_to<GraphControl>(get_child(i)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue with the variable name. Probably a bunch of others around all the touched files.
So, my overall impression so far is that we should split this into a few PRs (or at least a few commits, but with dedicated PRs we can merge them in steps, and not just review them easier).
I believe, that this way we can review, merge, and iterate quicker, as right now this PR contains A LOT of changes which are codestyle/cosmetic. And for the most part those changes seem independent from logical changes, so factoring them out into dedicated PR doesn't appear challenging to me. @Geometror Would you be up for following with this plan? Does it sound sensible to you? If so, we could probably be done with this within a week. I'll be here to quickly review each step. |
fb08d64
to
6c0d3e5
Compare
(snap->snapping, idx->index/slot_index, toggle_grid->grid_toggle for theme icon, minor code style fixes)
6c0d3e5
to
1b4299f
Compare
What the milestone for this? |
@nyabinary 4.2. This was split into several PRs to make the process easier for everyone. You can see them linked above your comment. |
Here are optimized/fixed versions for the new icons in this PRGraphControl: GraphEdit: GraphFrame: GraphNode: and GridToggle seems to already exist, so the PR adding it is probably a mistake. |
This PR is superseded by #79311 and its companions. Everything outlined here is now implemented. Feel free to open follow-up PRs to fix bugs and add new features and enhancements! |
This PR implements godotengine/godot-proposals#5271 for the most part.
Supersedes #61414 and #61783.
Detailed changes
Restructuring/Code style
Functional changes
Theming
Fixes
Future work
In my view, there are still some things left to do, but I wanted to get this out now to receive some feedback.
These are some of the things that I will work on next or in the future, that might require some discussion (and more time). These may go in their own PRs or if desired/necessary, in this one.