-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Add a flag to make the connection automatically emit the source object. #60143
base: master
Are you sure you want to change the base?
Conversation
23aac23
to
29786fc
Compare
Would work for the use case in godotengine/godot-proposals#3775 albeit in a different way than proposed |
I somewhat like this new flag, but the fact that it requires so much text to be explained properly concerns me and makes me question its simplicity.
|
The picture will make it clearer. These three categories have existed before. Just rarely notice them. This will affect the parameter list of the target method. Emitting the new source object first may avoid some unnecessary trouble. Now, if the flag bit is enable, the source object will be the first argument to emit. It will be easy to write the parameter list of the target function by hand. |
db29c50
to
00f13d5
Compare
00f13d5
to
4a47b7a
Compare
4a47b7a
to
f6f2713
Compare
f6f2713
to
d51edda
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.
Seems good, other than minor changes and variable renames. Great job on this feature!
core/object/object.cpp
Outdated
//handle binds | ||
bind_mem.resize(p_argcount + c.binds.size()); | ||
bind_mem.resize(source_count + p_argcount + c.binds.size()); |
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 for clarity the appended object should come at the end, not at the begining.
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.
If so, then use Callable.bind
in code to bind some parameters, it won't go at the end, just before those bound parameters.
Of course, for the Connection dialog, Callable.bind
will not be involved. It will be at the end.
Edit:
In the Connection dialog, the source object may be hidden by a non-zero unbind
and then invalidated. Therefore, only if it is placed at the beginning, it will not be affected by other parameters.
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.
Ah yeah, callable binds will come at the end, this makes sense.
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.
To be completely honest, I think we should remove connection binds and only use callable binds but this is quite a lot of work.
That said, I think the instance should come after the regular function arguments (even if it comes before the callable bind). This is because we only have the concept of appending arguments to functions. If we had to start discerning between prepending and appending it would be a mess.
d51edda
to
c859567
Compare
c859567
to
29cc676
Compare
core/object/object.cpp
Outdated
//handle binds | ||
bind_mem.resize(p_argcount + c.binds.size()); | ||
bind_mem.resize(source_count + p_argcount + c.binds.size()); |
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.
To be completely honest, I think we should remove connection binds and only use callable binds but this is quite a lot of work.
That said, I think the instance should come after the regular function arguments (even if it comes before the callable bind). This is because we only have the concept of appending arguments to functions. If we had to start discerning between prepending and appending it would be a mess.
The current feeling is that signal and connection binds know the parameters of the original callable, so their parameters are combined to be the parameters of the original callable; while
IMHO, right now, it actually feels a bit confusing about
On the other hand, it might make sense if we thought that the callable (the Receiver Method) was trying to receive these parameters. This is how I understand it.:
Of course, it would be better if the order could be reversed. |
I seem to be stuck in a chicken-and-egg dilemma. Let's go back to the beginning:
Honestly, this patch doesn't introduce much complexity. |
Heyo, I already removed the connection binds in #63595 so feel free to rebase your PR. I think for merging, as was discussed, the source object should be appended (right after the original signal arguments, before the callable binds) and not prepended. Other than that it looks good! |
29cc676
to
56ebec0
Compare
56ebec0
to
b467253
Compare
Now use a new commit to solve the The source object will be appended, right before the callable binds (if it exists), after the original signal arguments, after the callable |
9897987
to
31db271
Compare
a051fdd
to
9465dd5
Compare
9465dd5
to
f464dcd
Compare
Okay, don't really agree, but following your advice. Let's wait for the feedback from the users. |
For reference: #62891. |
f464dcd
to
0b0d580
Compare
d7c7ca7
to
440ff85
Compare
Mainly used to improve the connection dialog.
440ff85
to
aac14cc
Compare
I modified the usage condition of this option in connection dialog.
It is up to the user when used in scripts. It is more convenient to directly use |
Mainly used to improve the connection dialog.
It seems that the previous connection dialog only supports constant bindings. Though duplicating a node in the editor will also duplicate the existing connections, but we still need to adjust some parameters, and it's not very efficient to frequent operations in a pop-up dialog.
For existing connection-related parameters, these can be divided into three categories, listed in the order of use: the parameters of the signal, the
binds
arguments in the connection, the bound arguments of the callable.It is probably well known that the binding parameters in the connection dialog are the bound arguments of the callable.
In the current situation, it seems difficult for the receiver to know the information of the signal sender when only use the connection dialog.
In this commit, add a flag bit
ConnectFlags.CONNECT_SOURCE_AUTOBIND
to make the connection automatically emit the source object.If this flag bit is enabled, the source object will be emitted
at the end of the emitted parameters, right before the bound arguments of the callable.at first, no matter what the other parameters are.Hopefully this will make the connection dialog a bit more usable.
https://user-images.githubusercontent.com/30386067/162772481-c046b302-178d-41ba-ae8b-145c67ba3a39.mp4the.source.emitted.first.mp4