Skip to content
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

Expose "editable_instance" to scripting + Update C++ API #46006

Closed
wants to merge 1 commit into from
Closed

Expose "editable_instance" to scripting + Update C++ API #46006

wants to merge 1 commit into from

Conversation

revilo
Copy link
Contributor

@revilo revilo commented Feb 14, 2021

This PR fixes #20292.

Changes:

  1. Exposes the editable_instance flag to scripts:

node_editable_instance

This will allow easier implementation of undo/redo for turning on/off the "Editable children" option and its related actions in the editor.

  1. Modified the C++ interface of editable_instance to simplify its usage and to better reflect how it works today:
	// old interface
	void set_editable_instance(Node *p_node, bool p_editable);
	bool is_editable_instance(const Node *p_node) const;

	// new interface
	void set_editable_instance(bool p_editable);
	bool is_editable_instance() const;

In the previous implementation, the set_editable_instance and is_editable_instance got called on the owner of a node:

	// old usage
	owner->set_editable_instance(child, true);

This was for historical reasons, as initially the editable_children were managed in a list inside the owner. Today the "editable" state is a simple flag in the Node class itself, and therefore the interface should reflect this:

	// new usage
	child->set_editable_instance(true);
  1. Updated all calls to set_editable_instance and is_editable_instance throughout the source code.

@revilo revilo requested a review from a team as a code owner February 14, 2021 09:40
@revilo revilo changed the title Expose "editable_instance" to scripting Expose "editable_instance" to scripting + Update API Feb 14, 2021
@revilo revilo changed the title Expose "editable_instance" to scripting + Update API Expose "editable_instance" to scripting + Update C++ API Feb 14, 2021
…ifies "set_editable_instance" and "is_editable_instance" to better reflect how they work now
@revilo
Copy link
Contributor Author

revilo commented Feb 14, 2021

I've just seen this comment on another PR saying that having "editable_instance" in the scripting API of Node is not wanted:

#20569 (comment)

What is your opinion on the proposed API change of set_editable_instance and is_editable_instance?

@Calinou Calinou added enhancement topic:core cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Feb 14, 2021
@Calinou Calinou added this to the 4.0 milestone Feb 14, 2021
@hilfazer
Copy link
Contributor

hilfazer commented Feb 14, 2021

What is your opinion on the proposed API change of set_editable_instance and is_editable_instance?

They could be in a separate PR.

@revilo
Copy link
Contributor Author

revilo commented Feb 15, 2021

They could be in a seperate PR.

Ok, will do so when #20292 gets closed.

@hilfazer
Copy link
Contributor

Changes to the API should probably wait until current issues (#46261) caused by the new way of storing editable children info are resolved.

@hilfazer
Copy link
Contributor

hilfazer commented Mar 20, 2021

While exposing 'editable_children' may happen in the future it'll probably require a system for distinguishing editor-only properties/methods, as Akien mentioned here #20569 (comment).

I suggest not to wait, remove that part and rename the PR accordingly.

@revilo
Copy link
Contributor Author

revilo commented Apr 2, 2021

Closed since "editable_instance" is currently not supposed to be exposed to scripting.
The API changes will be submitted in a separate PR.

@revilo revilo closed this Apr 2, 2021
@akien-mga akien-mga added archived and removed cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose editable_children option to scripts
4 participants