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

Enhance NodePath property editing #75274

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Mar 23, 2023

  • Change Clear button to a menu
  • Add "Copy as Text" option, to copy the NodePath as text (accepts invalid paths too, so you can reference singletons or nodes from other scenes etc.)
  • Add "Edit" option, to edit the NodePath manually
  • Add "Show Node in Tree", which selects the target node (if available)
Code_k9ydA6CGlm.mp4

Closes #25289

menu->connect(SNAME("about_to_popup"), callable_mp(this, &EditorPropertyNodePath::_update_menu));
hbc->add_child(menu);

menu->get_popup()->add_item(TTR("Clear"), ACTION_CLEAR);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: Why not take a reference/pointer to the popup and then popup->add_item(x)? I'm seeing such pattern (repeating getters or whatever on multiple lines) quite often in Godot's code base.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk, I just haven't thought about that. It's not like it's done consistently.

@MewPurPur
Copy link
Contributor

I assume most people mainly need editing and clearing, so I'm wondering if we can spare the extra click so clearing a bunch of node paths doesn't take 4 times as long...

  • Edit could be replaced by a line edit in the node selection menu.
  • Copy as Text can be copied from that line edit, and we also have the "Copy Value" functionality on properties anyway.
  • Can't think of anything different for View in Tree, so maybe it could be a second button

@ajreckof
Copy link
Member

  • Change Clear button to a menu

I'm not too sure about this but would it be possible to add them it to the menu that pops on right click and has "copy/paste value" instead of creating a new menu.

  • Add "Copy as Text" option, to copy the NodePath as text (accepts invalid paths too, so you can reference singletons or nodes from other scenes etc.)

It feels like "copy / paste Value" should work like that instead of creating another functionality for it

  • Add "Edit" option, to edit the NodePath manually

I think this should replace the clear button. But maybe this is just me as i mostly never use it and use the revert to default button.

@akien-mga
Copy link
Member

Needs rebase. Then maybe @Calinou can review?

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 2, 2023

Rebased. I ended up doing some refactoring, but I kept the behavior for now.
I considered replacing the menu button with right-click context menu, but a button is better for discoverability.

@Calinou
Copy link
Member

Calinou commented Oct 4, 2023

I considered replacing the menu button with right-click context menu, but a button is better for discoverability.

I'd suggest supporting both if possible 🙂

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally (rebased on top of master f5696c3), it works as expected. Code looks good to me too.

A small UX issue I noticed is that when you use Show node in Tree, the focus will appear on the node in question (with the outline), but the old node remains selected:

image

I wonder if it should switch to the new node in the inspector automatically (and remove the selection on the current node instead). Still, this isn't blocking and can be refined in a future PR (like warning users if they enter a node path that isn't known to exist at compile-time).

@KoBeWi
Copy link
Member Author

KoBeWi commented Oct 4, 2023

I could experiment with selecting single node, but either it would switch the inspector (so the node you were editing right now would disappear) or, if it's possible to preserve edited node, the inspector would show old node with another one selected in scene tree. Maybe the latter is fine, same happens when you are dragging a node.

@akien-mga akien-mga merged commit 7a0fc7e into godotengine:master Oct 4, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

3.1 NodePath inspector widget is less functional than previous 3.0 version
7 participants