Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <eiseljulian@gmail.com>2015-06-12 05:42:31 +0300
committerJulian Eisel <eiseljulian@gmail.com>2015-06-12 05:46:49 +0300
commit220595027498b8e55c071b2388ac3be2859b94af (patch)
tree70b319d9d423779663df9757e06cb409adf07017 /source/blender/editors
parent6a33d13ae7a4f87188f08dda68f690948ecdf823 (diff)
File Browser: Ensure active file is unset if no file is selected
Otherwise arrow keys navigation might start from this file instead of the last/first file in the list.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_file/file_ops.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index fcb84004448..4889b775849 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -215,6 +215,23 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen)
return retval;
}
+/**
+ * \warning: loops over all files so better use cautiously
+ */
+static bool file_is_any_selected(struct FileList *files)
+{
+ const int numfiles = filelist_numfiles(files);
+ int i;
+
+ for (i = 0; i < numfiles; ++i) {
+ if (filelist_is_selected(files, i, CHECK_ALL)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, bool fill, bool do_diropen)
{
@@ -230,36 +247,23 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select,
if (sel.first != sel.last) select = 0;
/* Do we have a valid selection and are we actually selecting */
- if ((sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE))) {
+ if ((sel.last >= 0) && (select != FILE_SEL_REMOVE)) {
/* Check last selection, if selected, act on the file or dir */
if (filelist_is_selected(sfile->files, sel.last, check_type)) {
retval = file_select_do(C, sel.last, do_diropen);
}
}
+ if (select != FILE_SEL_ADD && !file_is_any_selected(sfile->files)) {
+ sfile->params->active_file = -1;
+ }
+
/* update operator for name change event */
file_draw_check(C);
return retval;
}
-/**
- * \warning: loops over all files so better use cautiously
- */
-static bool file_is_any_selected(struct FileList *files)
-{
- const int numfiles = filelist_numfiles(files);
- int i;
-
- for (i = 0; i < numfiles; ++i) {
- if (filelist_is_selected(files, i, CHECK_ALL)) {
- return true;
- }
- }
-
- return false;
-}
-
static int file_border_select_find_last_selected(
SpaceFile *sfile, ARegion *ar, const FileSelection *sel,
const int mouse_xy[2])
@@ -680,6 +684,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
/* select all only if previously no file was selected */
if (has_selection) {
filelist_select(sfile->files, &sel, FILE_SEL_REMOVE, FILE_SEL_SELECTED, CHECK_ALL);
+ sfile->params->active_file = -1;
}
else {
const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_FILES;