diff options
author | Andrea Weikert <elubie@gmx.net> | 2011-03-20 03:34:08 +0300 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2011-03-20 03:34:08 +0300 |
commit | ef9356043ea6c093506096116bf879197224aa25 (patch) | |
tree | 7b99090cc588966c5dcafe832ff5fe96a6650257 /source/blender/editors/space_file/file_ops.c | |
parent | 35dbf67c0019d433ba1be2dc52ced592f591afd1 (diff) |
== file browser ==
Patch from Alexander Kuznetsov: Real-time File Selection, thanks for the contribution.
Still made a few minor changes from latest patch:
1. Rename SELECTEDFILE to HILITED_FILE, since we are not actually selecting the file, but previewing/highliting the possible selection.
2. Also made this clearer by not drawing the files as selected, but just highlight them.
3. Removed the Select/Deselect toggle when clicking on file, will be committed separately soon.
Diffstat (limited to 'source/blender/editors/space_file/file_ops.c')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 37f4569d55a..21880a6b0c6 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -225,6 +225,44 @@ static FileSelect file_select(bContext* C, const rcti* rect, short select, short return retval; } +static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceFile *sfile= CTX_wm_space_file(C); + FileSelectParams *params = ED_fileselect_get_params(sfile); + FileSelection sel; + rcti rect; + + int result; + + result= WM_border_select_modal(C, op, event); + + if(result==OPERATOR_RUNNING_MODAL) { + + rect.xmin= RNA_int_get(op->ptr, "xmin"); + rect.ymin= RNA_int_get(op->ptr, "ymin"); + rect.xmax= RNA_int_get(op->ptr, "xmax"); + rect.ymax= RNA_int_get(op->ptr, "ymax"); + + BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect); + + sel = file_selection_get(C, &rect, 0); + if ( (sel.first != params->sel_first) || (sel.last != params->sel_last) ) { + file_deselect_all(sfile, HILITED_FILE); + filelist_select(sfile->files, &sel, 1, HILITED_FILE); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + } + params->sel_first = sel.first; params->sel_last = sel.last; + + }else { + params->active_file = -1; + params->sel_first = params->sel_last = -1; + file_deselect_all(sfile, HILITED_FILE); + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); + } + + return result; +} static int file_border_select_exec(bContext *C, wmOperator *op) { @@ -259,7 +297,7 @@ void FILE_OT_select_border(wmOperatorType *ot) /* api callbacks */ ot->invoke= WM_border_select_invoke; ot->exec= file_border_select_exec; - ot->modal= WM_border_select_modal; + ot->modal= file_border_select_modal; ot->poll= ED_operator_file_active; /* rna */ |