From 5325f3b2e989a3b94e2d9450c574e4610d2005d8 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sun, 20 Mar 2011 10:22:51 +0000 Subject: == file browser == Patch from Alexander Kuznetsov: Toggle selection rather than just extending. Implements behaviour that unintendedly was available with previously using macro operator for selection. This was removed and now the functionality is properly implemented. Patch accepted with minor changes: 1. Used enum rather than #defines and added value for removing from selection (deselect) 2. Moved if (select) outside file_select_do and improved check for whether last file in selection is actually selected. (Necessary since toggle can deselect and toggle select should still make file active) 3. Additionally fixed check in file_select_invoke to be consistent with border select. --- source/blender/editors/space_file/filelist.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/space_file/filelist.c') diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 5fb64b2f2bc..3c76b815a80 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -926,7 +926,7 @@ void filelist_swapselect(struct FileList* filelist) } } -void filelist_select(struct FileList* filelist, FileSelection* sel, short select, unsigned int flag) +void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType select, unsigned int flag) { /* select all valid files between first and last indicated */ if ( (sel->first >= 0) && (sel->first < filelist->numfiltered) && (sel->last >= 0) && (sel->last < filelist->numfiltered) ) { @@ -934,10 +934,17 @@ void filelist_select(struct FileList* filelist, FileSelection* sel, short select for (current_file = sel->first; current_file <= sel->last; current_file++) { struct direntry* file = filelist_file(filelist, current_file); - if (select) - file->flags |= flag; - else - file->flags &= ~flag; + switch (select) { + case FILE_SEL_REMOVE: + file->flags &= ~flag; + break; + case FILE_SEL_ADD: + file->flags |= flag; + break; + case FILE_SEL_TOGGLE: + file->flags ^= flag; + break; + } } } } -- cgit v1.2.3