forked from bartvdbraak/blender
== 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.
This commit is contained in:
parent
35dbf67c00
commit
ef9356043e
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -188,7 +188,8 @@ typedef struct FileSelectParams {
|
||||
short active_bookmark;
|
||||
|
||||
int active_file;
|
||||
int selstate;
|
||||
int sel_first;
|
||||
int sel_last;
|
||||
|
||||
/* short */
|
||||
/* XXX --- still unused -- */
|
||||
@ -728,6 +729,7 @@ enum FileSortTypeE {
|
||||
#define BTXFILE (1<<12)
|
||||
#define COLLADAFILE (1<<13)
|
||||
#define OPERATORFILE (1<<14) /* from filter_glob operator property */
|
||||
#define HILITED_FILE (1<<15)
|
||||
|
||||
/* SpaceImage->dt_uv */
|
||||
#define SI_UVDT_OUTLINE 0
|
||||
|
@ -2075,31 +2075,34 @@ void WM_paint_cursor_end(wmWindowManager *wm, void *handle)
|
||||
It stores 4 values (xmin, xmax, ymin, ymax) and event it ended with (event_type)
|
||||
*/
|
||||
|
||||
static int border_apply(bContext *C, wmOperator *op, int gesture_mode)
|
||||
static int border_apply_rect(bContext *C, wmOperator *op)
|
||||
{
|
||||
wmGesture *gesture= op->customdata;
|
||||
rcti *rect= gesture->customdata;
|
||||
|
||||
if(rect->xmin > rect->xmax)
|
||||
SWAP(int, rect->xmin, rect->xmax);
|
||||
if(rect->ymin > rect->ymax)
|
||||
SWAP(int, rect->ymin, rect->ymax);
|
||||
|
||||
if(rect->xmin==rect->xmax || rect->ymin==rect->ymax)
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
/* operator arguments and storage. */
|
||||
RNA_int_set(op->ptr, "xmin", rect->xmin);
|
||||
RNA_int_set(op->ptr, "ymin", rect->ymin);
|
||||
RNA_int_set(op->ptr, "xmax", rect->xmax);
|
||||
RNA_int_set(op->ptr, "ymax", rect->ymax);
|
||||
RNA_int_set(op->ptr, "xmin", MIN2(rect->xmin, rect->xmax) );
|
||||
RNA_int_set(op->ptr, "ymin", MIN2(rect->ymin, rect->ymax) );
|
||||
RNA_int_set(op->ptr, "xmax", MAX2(rect->xmin, rect->xmax) );
|
||||
RNA_int_set(op->ptr, "ymax", MAX2(rect->ymin, rect->ymax) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int border_apply(bContext *C, wmOperator *op, int gesture_mode)
|
||||
{
|
||||
if (!border_apply_rect(C, op))
|
||||
return 0;
|
||||
|
||||
/* XXX weak; border should be configured for this without reading event types */
|
||||
if( RNA_struct_find_property(op->ptr, "gesture_mode") )
|
||||
RNA_int_set(op->ptr, "gesture_mode", gesture_mode);
|
||||
|
||||
op->type->exec(C, op);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2148,6 +2151,7 @@ int WM_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
rect->xmax= event->x - sx;
|
||||
rect->ymax= event->y - sy;
|
||||
}
|
||||
border_apply_rect(C, op);
|
||||
|
||||
wm_gesture_tag_redraw(C);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user