|
@@ -190,8 +190,6 @@ void ScenesDock::_notification(int p_what) {
|
|
|
|
|
|
button_reload->set_icon( get_icon("Reload","EditorIcons"));
|
|
|
button_favorite->set_icon( get_icon("Favorites","EditorIcons"));
|
|
|
- button_fav_up->set_icon( get_icon("MoveUp","EditorIcons"));
|
|
|
- button_fav_down->set_icon( get_icon("MoveDown","EditorIcons"));
|
|
|
//button_instance->set_icon( get_icon("Add","EditorIcons"));
|
|
|
//button_open->set_icon( get_icon("Folder","EditorIcons"));
|
|
|
button_back->set_icon( get_icon("Filesystem","EditorIcons"));
|
|
@@ -201,7 +199,7 @@ void ScenesDock::_notification(int p_what) {
|
|
|
files->connect("item_activated",this,"_select_file");
|
|
|
button_hist_next->connect("pressed",this,"_fw_history");
|
|
|
button_hist_prev->connect("pressed",this,"_bw_history");
|
|
|
- search_button->set_icon( get_icon("Zoom","EditorIcons"));
|
|
|
+ search_icon->set_texture( get_icon("Zoom","EditorIcons"));
|
|
|
|
|
|
button_hist_next->set_icon( get_icon("Forward","EditorIcons"));
|
|
|
button_hist_prev->set_icon( get_icon("Back","EditorIcons"));
|
|
@@ -228,10 +226,16 @@ void ScenesDock::_notification(int p_what) {
|
|
|
case NOTIFICATION_DRAG_BEGIN: {
|
|
|
|
|
|
Dictionary dd = get_viewport()->gui_get_drag_data();
|
|
|
- if (tree->is_visible() && dd.has("type") && (
|
|
|
- (String(dd["type"])=="files") || (String(dd["type"])=="files_and_dirs") || (String(dd["type"])=="resource"))) {
|
|
|
- tree->set_drop_mode_flags(Tree::DROP_MODE_ON_ITEM);
|
|
|
+ if (tree->is_visible() && dd.has("type") ) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ if ( (String(dd["type"])=="favorite") ) {
|
|
|
+ tree->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
} break;
|
|
|
case NOTIFICATION_DRAG_END: {
|
|
|
|
|
@@ -272,11 +276,7 @@ void ScenesDock::_dir_selected() {
|
|
|
if (ti->get_parent() && ti->get_parent()->get_parent()==tree->get_root() && !ti->get_parent()->get_prev()) {
|
|
|
|
|
|
//a favorite!!!
|
|
|
- button_fav_up->set_disabled(!ti->get_prev());
|
|
|
- button_fav_down->set_disabled(!ti->get_next());
|
|
|
} else {
|
|
|
- button_fav_up->set_disabled(true);
|
|
|
- button_fav_down->set_disabled(true);
|
|
|
|
|
|
|
|
|
}
|
|
@@ -287,83 +287,6 @@ void ScenesDock::_dir_selected() {
|
|
|
|
|
|
}
|
|
|
|
|
|
-void ScenesDock::_fav_up_pressed() {
|
|
|
-
|
|
|
- TreeItem *sel = tree->get_selected();
|
|
|
- if (!sel)
|
|
|
- return ;
|
|
|
-
|
|
|
- if (!sel->get_prev())
|
|
|
- return;
|
|
|
-
|
|
|
- String sw = sel->get_prev()->get_metadata(0);
|
|
|
- String txt = sel->get_metadata(0);
|
|
|
-
|
|
|
- Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
-
|
|
|
- int a_idx=favorited.find(sw);
|
|
|
- int b_idx=favorited.find(txt);
|
|
|
-
|
|
|
- if (a_idx==-1 || b_idx==-1)
|
|
|
- return;
|
|
|
- SWAP(favorited[a_idx],favorited[b_idx]);
|
|
|
-
|
|
|
- EditorSettings::get_singleton()->set_favorite_dirs(favorited);
|
|
|
-
|
|
|
- _update_tree();
|
|
|
-
|
|
|
- if (!tree->get_root() || !tree->get_root()->get_children() || !tree->get_root()->get_children()->get_children())
|
|
|
- return;
|
|
|
- sel = tree->get_root()->get_children()->get_children();
|
|
|
- while(sel) {
|
|
|
-
|
|
|
- String t = sel->get_metadata(0);
|
|
|
- if (t==txt) {
|
|
|
- sel->select(0);
|
|
|
- return;
|
|
|
- }
|
|
|
- sel=sel->get_next();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-void ScenesDock::_fav_down_pressed() {
|
|
|
-
|
|
|
- TreeItem *sel = tree->get_selected();
|
|
|
- if (!sel)
|
|
|
- return ;
|
|
|
-
|
|
|
- if (!sel->get_next())
|
|
|
- return;
|
|
|
-
|
|
|
- String sw = sel->get_next()->get_metadata(0);
|
|
|
- String txt = sel->get_metadata(0);
|
|
|
-
|
|
|
- Vector<String> favorited = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
-
|
|
|
- int a_idx=favorited.find(sw);
|
|
|
- int b_idx=favorited.find(txt);
|
|
|
-
|
|
|
- if (a_idx==-1 || b_idx==-1)
|
|
|
- return;
|
|
|
- SWAP(favorited[a_idx],favorited[b_idx]);
|
|
|
-
|
|
|
- EditorSettings::get_singleton()->set_favorite_dirs(favorited);
|
|
|
-
|
|
|
- _update_tree();
|
|
|
-
|
|
|
- if (!tree->get_root() || !tree->get_root()->get_children() || !tree->get_root()->get_children()->get_children())
|
|
|
- return;
|
|
|
- sel = tree->get_root()->get_children()->get_children();
|
|
|
- while(sel) {
|
|
|
-
|
|
|
- String t = sel->get_metadata(0);
|
|
|
- if (t==txt) {
|
|
|
- sel->select(0);
|
|
|
- return;
|
|
|
- }
|
|
|
- sel=sel->get_next();
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
void ScenesDock::_favorites_pressed() {
|
|
|
|
|
@@ -499,7 +422,7 @@ void ScenesDock::_update_files(bool p_keep_selection) {
|
|
|
Ref<Texture> file_thumbnail;
|
|
|
|
|
|
bool use_thumbnails=!display_mode->is_pressed();
|
|
|
- bool use_folders = !search_box->is_visible() && split_mode;
|
|
|
+ bool use_folders = search_box->get_text().length()==0 && split_mode;
|
|
|
|
|
|
if (use_thumbnails) { //thumbnails
|
|
|
|
|
@@ -579,7 +502,7 @@ void ScenesDock::_update_files(bool p_keep_selection) {
|
|
|
|
|
|
List<FileInfo> filelist;
|
|
|
|
|
|
- if (search_box->is_visible()) {
|
|
|
+ if (search_box->get_text().length()) {
|
|
|
|
|
|
if (search_box->get_text().length()>1) {
|
|
|
_search(EditorFileSystem::get_singleton()->get_filesystem(),&filelist,128);
|
|
@@ -653,8 +576,6 @@ void ScenesDock::_go_to_tree() {
|
|
|
tree->grab_focus();
|
|
|
tree->ensure_cursor_is_visible();
|
|
|
button_favorite->show();
|
|
|
- button_fav_up->show();
|
|
|
- button_fav_down->show();
|
|
|
//button_open->hide();
|
|
|
//file_options->hide();
|
|
|
}
|
|
@@ -680,8 +601,6 @@ void ScenesDock::_fs_changed() {
|
|
|
|
|
|
if (!tree->is_hidden()) {
|
|
|
button_favorite->show();
|
|
|
- button_fav_up->show();
|
|
|
- button_fav_down->show();
|
|
|
_update_tree();
|
|
|
|
|
|
}
|
|
@@ -1100,8 +1019,6 @@ void ScenesDock::_open_pressed(){
|
|
|
tree->hide();
|
|
|
file_list_vb->show();
|
|
|
button_favorite->hide();
|
|
|
- button_fav_up->hide();
|
|
|
- button_fav_down->hide();
|
|
|
}
|
|
|
|
|
|
//file_options->show();
|
|
@@ -1114,26 +1031,6 @@ void ScenesDock::_open_pressed(){
|
|
|
|
|
|
}
|
|
|
|
|
|
-void ScenesDock::_search_toggled(){
|
|
|
-
|
|
|
- if (search_button->is_pressed()) {
|
|
|
- //search_box->clear();
|
|
|
- search_box->select_all();
|
|
|
- search_box->show();
|
|
|
- current_path->hide();
|
|
|
- search_box->grab_focus();
|
|
|
-
|
|
|
- _update_files(false);
|
|
|
- } else {
|
|
|
-
|
|
|
- //search_box->clear();
|
|
|
- search_box->hide();
|
|
|
- current_path->show();
|
|
|
-
|
|
|
- _update_files(false);
|
|
|
-
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
void ScenesDock::_search_changed(const String& p_text) {
|
|
|
|
|
@@ -1180,7 +1077,14 @@ Variant ScenesDock::get_drag_data_fw(const Point2& p_point,Control* p_from) {
|
|
|
path=path+"/";
|
|
|
Vector<String> paths;
|
|
|
paths.push_back(path);
|
|
|
- return EditorNode::get_singleton()->drag_files(paths,p_from);
|
|
|
+ Dictionary d = EditorNode::get_singleton()->drag_files(paths,p_from);
|
|
|
+
|
|
|
+ if (selected->get_parent() && tree->get_root()->get_children()==selected->get_parent()) {
|
|
|
+ //a favorite.. treat as such
|
|
|
+ d["type"]="favorite";
|
|
|
+ }
|
|
|
+
|
|
|
+ return d;
|
|
|
|
|
|
}
|
|
|
|
|
@@ -1239,6 +1143,30 @@ bool ScenesDock::can_drop_data_fw(const Point2& p_point,const Variant& p_data,Co
|
|
|
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
|
+ if (drag_data.has("type") && String(drag_data["type"])=="favorite") {
|
|
|
+
|
|
|
+ //moving favorite around
|
|
|
+ TreeItem *ti = tree->get_item_at_pos(p_point);
|
|
|
+ if (!ti)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ int what = tree->get_drop_section_at_pos(p_point);
|
|
|
+
|
|
|
+ if (ti==tree->get_root()->get_children()) {
|
|
|
+ return (what==1); //the parent, first fav
|
|
|
+ }
|
|
|
+ if (ti->get_parent() && tree->get_root()->get_children()==ti->get_parent()) {
|
|
|
+ return true; // a favorite
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ti==tree->get_root()->get_children()->get_next()) {
|
|
|
+ return (what==-1); //the tree, last fav
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (drag_data.has("type") && String(drag_data["type"])=="resource") {
|
|
|
return true;
|
|
@@ -1283,6 +1211,69 @@ void ScenesDock::drop_data_fw(const Point2& p_point,const Variant& p_data,Contro
|
|
|
return;
|
|
|
Dictionary drag_data = p_data;
|
|
|
|
|
|
+ if (drag_data.has("type") && String(drag_data["type"])=="favorite") {
|
|
|
+
|
|
|
+ //moving favorite around
|
|
|
+ TreeItem *ti = tree->get_item_at_pos(p_point);
|
|
|
+ if (!ti)
|
|
|
+ return;
|
|
|
+
|
|
|
+ Vector<String> files = drag_data["files"];
|
|
|
+
|
|
|
+ ERR_FAIL_COND(files.size()!=1);
|
|
|
+
|
|
|
+ String swap = files[0];
|
|
|
+ if (swap!="res://" && swap.ends_with("/")) {
|
|
|
+ swap=swap.substr(0,swap.length()-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ int what = tree->get_drop_section_at_pos(p_point);
|
|
|
+
|
|
|
+ TreeItem *swap_item=NULL;
|
|
|
+
|
|
|
+ if (ti==tree->get_root()->get_children()) {
|
|
|
+ swap_item=tree->get_root()->get_children()->get_children();
|
|
|
+
|
|
|
+ } else if (ti->get_parent() && tree->get_root()->get_children()==ti->get_parent()) {
|
|
|
+ if (what==-1) {
|
|
|
+ swap_item=ti;
|
|
|
+ } else {
|
|
|
+ swap_item=ti->get_next();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String swap_with;
|
|
|
+
|
|
|
+ if (swap_item) {
|
|
|
+ swap_with=swap_item->get_metadata(0);
|
|
|
+ if (swap_with!="res://" && swap_with.ends_with("/")) {
|
|
|
+ swap_with=swap_with.substr(0,swap_with.length()-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (swap==swap_with)
|
|
|
+ return;
|
|
|
+
|
|
|
+ Vector<String> dirs = EditorSettings::get_singleton()->get_favorite_dirs();
|
|
|
+
|
|
|
+ ERR_FAIL_COND(dirs.find(swap)==-1);
|
|
|
+ ERR_FAIL_COND(swap_with!=String() && dirs.find(swap_with)==-1);
|
|
|
+
|
|
|
+ dirs.erase(swap);
|
|
|
+
|
|
|
+ if (swap_with==String()) {
|
|
|
+ dirs.push_back(swap);
|
|
|
+ } else {
|
|
|
+ int idx = dirs.find(swap_with);
|
|
|
+ dirs.insert(idx,swap);
|
|
|
+ }
|
|
|
+
|
|
|
+ EditorSettings::get_singleton()->set_favorite_dirs(dirs);
|
|
|
+ _update_tree();
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if (drag_data.has("type") && String(drag_data["type"])=="resource") {
|
|
|
Ref<Resource> res = drag_data["resource"];
|
|
|
|
|
@@ -1449,12 +1440,10 @@ void ScenesDock::_bind_methods() {
|
|
|
ObjectTypeDB::bind_method(_MD("_bw_history"), &ScenesDock::_bw_history);
|
|
|
ObjectTypeDB::bind_method(_MD("_fs_changed"), &ScenesDock::_fs_changed);
|
|
|
ObjectTypeDB::bind_method(_MD("_dir_selected"), &ScenesDock::_dir_selected);
|
|
|
- ObjectTypeDB::bind_method(_MD("_fav_up_pressed"), &ScenesDock::_fav_up_pressed);
|
|
|
- ObjectTypeDB::bind_method(_MD("_fav_down_pressed"), &ScenesDock::_fav_down_pressed);
|
|
|
ObjectTypeDB::bind_method(_MD("_file_option"), &ScenesDock::_file_option);
|
|
|
ObjectTypeDB::bind_method(_MD("_move_operation"), &ScenesDock::_move_operation);
|
|
|
ObjectTypeDB::bind_method(_MD("_rename_operation"), &ScenesDock::_rename_operation);
|
|
|
- ObjectTypeDB::bind_method(_MD("_search_toggled"), &ScenesDock::_search_toggled);
|
|
|
+
|
|
|
ObjectTypeDB::bind_method(_MD("_search_changed"), &ScenesDock::_search_changed);
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("get_drag_data_fw"), &ScenesDock::get_drag_data_fw);
|
|
@@ -1487,28 +1476,21 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
|
|
|
button_hist_next->set_focus_mode(FOCUS_NONE);
|
|
|
button_hist_next->set_tooltip(TTR("Next Directory"));
|
|
|
|
|
|
+ current_path=memnew( LineEdit );
|
|
|
+ current_path->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
+ toolbar_hbc->add_child(current_path);
|
|
|
+
|
|
|
+
|
|
|
button_reload = memnew( Button );
|
|
|
button_reload->set_flat(true);
|
|
|
button_reload->connect("pressed",this,"_rescan");
|
|
|
toolbar_hbc->add_child(button_reload);
|
|
|
button_reload->set_focus_mode(FOCUS_NONE);
|
|
|
button_reload->set_tooltip(TTR("Re-Scan Filesystem"));
|
|
|
+ button_reload->hide();
|
|
|
|
|
|
- toolbar_hbc->add_spacer();
|
|
|
-
|
|
|
- button_fav_up = memnew( ToolButton );
|
|
|
- button_fav_up->set_flat(true);
|
|
|
- toolbar_hbc->add_child(button_fav_up);
|
|
|
- button_fav_up->set_disabled(true);
|
|
|
- button_fav_up->connect("pressed",this,"_fav_up_pressed");
|
|
|
- button_fav_up->set_tooltip(TTR("Move Favorite Up"));
|
|
|
+ //toolbar_hbc->add_spacer();
|
|
|
|
|
|
- button_fav_down = memnew( ToolButton );
|
|
|
- button_fav_down->set_flat(true);
|
|
|
- toolbar_hbc->add_child(button_fav_down);
|
|
|
- button_fav_down->set_disabled(true);
|
|
|
- button_fav_down->connect("pressed",this,"_fav_down_pressed");
|
|
|
- button_fav_down->set_tooltip(TTR("Move Favorite Down"));
|
|
|
|
|
|
button_favorite = memnew( Button );
|
|
|
button_favorite->set_flat(true);
|
|
@@ -1518,8 +1500,10 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
|
|
|
button_favorite->set_tooltip(TTR("Toggle folder status as Favorite"));
|
|
|
|
|
|
button_favorite->set_focus_mode(FOCUS_NONE);
|
|
|
- button_fav_up->set_focus_mode(FOCUS_NONE);
|
|
|
- button_fav_down->set_focus_mode(FOCUS_NONE);
|
|
|
+
|
|
|
+ Control *spacer = memnew( Control);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/*
|
|
|
button_open = memnew( Button );
|
|
@@ -1577,20 +1561,15 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
|
|
|
button_back = memnew( ToolButton );
|
|
|
path_hb->add_child(button_back);
|
|
|
button_back->hide();
|
|
|
- current_path=memnew( LineEdit );
|
|
|
- current_path->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
- path_hb->add_child(current_path);
|
|
|
|
|
|
search_box = memnew( LineEdit );
|
|
|
search_box->set_h_size_flags(SIZE_EXPAND_FILL);
|
|
|
path_hb->add_child(search_box);
|
|
|
- search_box->hide();
|
|
|
search_box->connect("text_changed",this,"_search_changed");
|
|
|
|
|
|
- search_button = memnew( ToolButton );
|
|
|
- path_hb->add_child(search_button);
|
|
|
- search_button->set_toggle_mode(true );
|
|
|
- search_button->connect("pressed",this,"_search_toggled");
|
|
|
+ search_icon = memnew( TextureFrame );
|
|
|
+ search_icon->set_stretch_mode(TextureFrame::STRETCH_KEEP_CENTERED);
|
|
|
+ path_hb->add_child(search_icon);
|
|
|
|
|
|
display_mode = memnew( ToolButton );
|
|
|
path_hb->add_child(display_mode);
|
|
@@ -1641,6 +1620,7 @@ ScenesDock::ScenesDock(EditorNode *p_editor) {
|
|
|
path="res://";
|
|
|
|
|
|
|
|
|
+ add_constant_override("separation",3);
|
|
|
}
|
|
|
|
|
|
ScenesDock::~ScenesDock() {
|