Favorites dragable
This commit is contained in:
parent
119bf23720
commit
f1265541ee
1 changed files with 17 additions and 11 deletions
|
@ -333,10 +333,11 @@ void FileSystemDock::_notification(int p_what) {
|
||||||
case NOTIFICATION_DRAG_BEGIN: {
|
case NOTIFICATION_DRAG_BEGIN: {
|
||||||
Dictionary dd = get_viewport()->gui_get_drag_data();
|
Dictionary dd = get_viewport()->gui_get_drag_data();
|
||||||
if (tree->is_visible_in_tree() && dd.has("type")) {
|
if (tree->is_visible_in_tree() && dd.has("type")) {
|
||||||
if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
|
if (dd.has("favorite")) {
|
||||||
|
if ((String(dd["favorite"]) == "all"))
|
||||||
|
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
|
||||||
|
} else if ((String(dd["type"]) == "files") || (String(dd["type"]) == "files_and_dirs") || (String(dd["type"]) == "resource")) {
|
||||||
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM | Tree::DROP_MODE_INBETWEEN);
|
tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM | Tree::DROP_MODE_INBETWEEN);
|
||||||
} else if ((String(dd["type"]) == "favorite")) {
|
|
||||||
tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -1839,7 +1840,7 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
|
||||||
all_not_favorites &= !is_favorite;
|
all_not_favorites &= !is_favorite;
|
||||||
selected = tree->get_next_selected(selected);
|
selected = tree->get_next_selected(selected);
|
||||||
}
|
}
|
||||||
if (all_favorites) {
|
if (!all_not_favorites) {
|
||||||
paths = _tree_get_selected(false);
|
paths = _tree_get_selected(false);
|
||||||
} else {
|
} else {
|
||||||
paths = _tree_get_selected();
|
paths = _tree_get_selected();
|
||||||
|
@ -1857,12 +1858,9 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
|
||||||
if (paths.empty())
|
if (paths.empty())
|
||||||
return Variant();
|
return Variant();
|
||||||
|
|
||||||
if (!all_favorites && !all_not_favorites)
|
|
||||||
return Variant();
|
|
||||||
|
|
||||||
Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from);
|
Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from);
|
||||||
if (all_favorites) {
|
if (!all_not_favorites) {
|
||||||
drag_data["type"] = "favorite";
|
drag_data["favorite"] = all_favorites ? "all" : "mixed";
|
||||||
}
|
}
|
||||||
return drag_data;
|
return drag_data;
|
||||||
}
|
}
|
||||||
|
@ -1870,7 +1868,11 @@ Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from)
|
||||||
bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
|
||||||
Dictionary drag_data = p_data;
|
Dictionary drag_data = p_data;
|
||||||
|
|
||||||
if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
|
if (drag_data.has("favorite")) {
|
||||||
|
|
||||||
|
if (String(drag_data["favorite"]) != "all") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Moving favorite around.
|
// Moving favorite around.
|
||||||
TreeItem *ti = tree->get_item_at_position(p_point);
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
||||||
|
@ -1937,7 +1939,11 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data,
|
||||||
|
|
||||||
Vector<String> dirs = EditorSettings::get_singleton()->get_favorites();
|
Vector<String> dirs = EditorSettings::get_singleton()->get_favorites();
|
||||||
|
|
||||||
if (drag_data.has("type") && String(drag_data["type"]) == "favorite") {
|
if (drag_data.has("favorite")) {
|
||||||
|
|
||||||
|
if (String(drag_data["favorite"]) != "all") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Moving favorite around.
|
// Moving favorite around.
|
||||||
TreeItem *ti = tree->get_item_at_position(p_point);
|
TreeItem *ti = tree->get_item_at_position(p_point);
|
||||||
if (!ti)
|
if (!ti)
|
||||||
|
|
Loading…
Reference in a new issue