You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Highlight Node and NodePath properties as valid drop targets
This was already done for Resource properties; this just makes things consistent.
This commit is contained in:
@@ -2732,6 +2732,13 @@ void EditorPropertyNodePath::_node_assign() {
|
|||||||
scene_tree->popup_scenetree_dialog(n, get_base_node());
|
scene_tree->popup_scenetree_dialog(n, get_base_node());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPropertyNodePath::_assign_draw() {
|
||||||
|
if (dropping) {
|
||||||
|
Color color = get_theme_color(SNAME("accent_color"), EditorStringName(Editor));
|
||||||
|
assign->draw_rect(Rect2(Point2(), assign->get_size()), color, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPropertyNodePath::_update_menu() {
|
void EditorPropertyNodePath::_update_menu() {
|
||||||
const NodePath &np = _get_node_path();
|
const NodePath &np = _get_node_path();
|
||||||
|
|
||||||
@@ -2909,6 +2916,20 @@ void EditorPropertyNodePath::_notification(int p_what) {
|
|||||||
menu->get_popup()->set_item_icon(ACTION_EDIT, get_editor_theme_icon(SNAME("Edit")));
|
menu->get_popup()->set_item_icon(ACTION_EDIT, get_editor_theme_icon(SNAME("Edit")));
|
||||||
menu->get_popup()->set_item_icon(ACTION_SELECT, get_editor_theme_icon(SNAME("ExternalLink")));
|
menu->get_popup()->set_item_icon(ACTION_SELECT, get_editor_theme_icon(SNAME("ExternalLink")));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_DRAG_BEGIN: {
|
||||||
|
if (!is_read_only() && is_drop_valid(get_viewport()->gui_get_drag_data())) {
|
||||||
|
dropping = true;
|
||||||
|
assign->queue_redraw();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case NOTIFICATION_DRAG_END: {
|
||||||
|
if (dropping) {
|
||||||
|
dropping = false;
|
||||||
|
assign->queue_redraw();
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2949,6 +2970,7 @@ EditorPropertyNodePath::EditorPropertyNodePath() {
|
|||||||
assign->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
assign->set_auto_translate_mode(AUTO_TRANSLATE_MODE_DISABLED);
|
||||||
assign->set_expand_icon(true);
|
assign->set_expand_icon(true);
|
||||||
assign->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyNodePath::_node_assign));
|
assign->connect(SceneStringName(pressed), callable_mp(this, &EditorPropertyNodePath::_node_assign));
|
||||||
|
assign->connect(SceneStringName(draw), callable_mp(this, &EditorPropertyNodePath::_assign_draw));
|
||||||
SET_DRAG_FORWARDING_CD(assign, EditorPropertyNodePath);
|
SET_DRAG_FORWARDING_CD(assign, EditorPropertyNodePath);
|
||||||
hbc->add_child(assign);
|
hbc->add_child(assign);
|
||||||
|
|
||||||
|
|||||||
@@ -628,10 +628,12 @@ class EditorPropertyNodePath : public EditorProperty {
|
|||||||
SceneTreeDialog *scene_tree = nullptr;
|
SceneTreeDialog *scene_tree = nullptr;
|
||||||
bool use_path_from_scene_root = false;
|
bool use_path_from_scene_root = false;
|
||||||
bool editing_node = false;
|
bool editing_node = false;
|
||||||
|
bool dropping = false;
|
||||||
|
|
||||||
Vector<StringName> valid_types;
|
Vector<StringName> valid_types;
|
||||||
void _node_selected(const NodePath &p_path, bool p_absolute = true);
|
void _node_selected(const NodePath &p_path, bool p_absolute = true);
|
||||||
void _node_assign();
|
void _node_assign();
|
||||||
|
void _assign_draw();
|
||||||
Node *get_base_node();
|
Node *get_base_node();
|
||||||
void _update_menu();
|
void _update_menu();
|
||||||
void _menu_option(int p_idx);
|
void _menu_option(int p_idx);
|
||||||
|
|||||||
Reference in New Issue
Block a user