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 | |
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')
-rw-r--r-- | source/blender/editors/space_file/file_draw.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 40 |
2 files changed, 44 insertions, 10 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 9d68acc4d5e..68651674bd5 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -469,7 +469,6 @@ void file_draw_list(const bContext *C, ARegion *ar) uiBlock *block = uiBeginBlock(C, ar, "FileNames", UI_EMBOSS); int numfiles; int numfiles_layout; - int colorid = 0; int sx, sy; int offset; int textwidth, textheight; @@ -516,14 +515,11 @@ void file_draw_list(const bContext *C, ARegion *ar) if (!(file->flags & EDITING)) { - if (params->active_file == i) { - if (file->flags & ACTIVEFILE) colorid= TH_HILITE; - else colorid = TH_BACK; - draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid,20); - } else if (file->flags & ACTIVEFILE) { - colorid = TH_HILITE; - draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid,0); - } + if ((params->active_file == i) || (file->flags & HILITED_FILE) || (file->flags & ACTIVEFILE) ) { + int colorid = (file->flags & ACTIVEFILE) ? TH_HILITE : TH_BACK; + int shade = (params->active_file == i) || (file->flags & HILITED_FILE) ? 20 : 0; + draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid, shade); + } } uiSetRoundBox(0); 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 */ |