Page Menu
Home
Search
Configure Global Search
Log In
Files
F13942
RealTimeSelect_Final2.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Alexander Kuznetsov (alexk)
Nov 13 2013, 2:56 PM
Size
8 KB
Subscribers
None
RealTimeSelect_Final2.patch
View Options
Index: source/blender/blenlib/BLI_rect.h
===================================================================
--- source/blender/blenlib/BLI_rect.h (revision 33459)
+++ source/blender/blenlib/BLI_rect.h (working copy)
@@ -50,6 +50,7 @@
int BLI_rctf_is_empty(struct rctf *rect);
void BLI_init_rctf(struct rctf *rect, float xmin, float xmax, float ymin, float ymax);
void BLI_init_rcti(struct rcti *rect, int xmin, int xmax, int ymin, int ymax);
+void BLI_norm_rcti(struct rcti *rect1, struct rcti *rect2);
void BLI_translate_rctf(struct rctf *rect, float x, float y);
void BLI_translate_rcti(struct rcti *rect, int x, int y);
void BLI_resize_rcti(struct rcti *rect, int x, int y);
Index: source/blender/blenlib/intern/rct.c
===================================================================
--- source/blender/blenlib/intern/rct.c (revision 33459)
+++ source/blender/blenlib/intern/rct.c (working copy)
@@ -129,6 +129,12 @@
}
}
+void BLI_norm_rcti(rcti *rect1, rcti *rect2)
+{
+ BLI_init_rcti(rect1, rect2->xmin, rect2->xmax, rect2->ymin, rect2->ymax);
+}
+
+
void BLI_translate_rcti(rcti *rect, int x, int y)
{
rect->xmin += x;
Index: source/blender/editors/space_file/file_draw.c
===================================================================
--- source/blender/editors/space_file/file_draw.c (revision 33459)
+++ source/blender/editors/space_file/file_draw.c (working copy)
@@ -508,11 +508,11 @@
if (!(file->flags & EDITING)) {
- if (params->active_file == i) {
+ if (params->active_file == i && !(file->flags & SELECTINGFILE)) {
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) {
+ } else if (file->flags & ACTIVEFILE || file->flags & SELECTINGFILE) {
colorid = TH_HILITE;
draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid,0);
}
Index: source/blender/editors/space_file/file_ops.c
===================================================================
--- source/blender/editors/space_file/file_ops.c (revision 33459)
+++ source/blender/editors/space_file/file_ops.c (working copy)
@@ -80,23 +80,40 @@
}
-static void file_deselect_all(SpaceFile* sfile)
+static void file_deselect_all(SpaceFile* sfile, int value)
{
int numfiles = filelist_numfiles(sfile->files);
int i;
for ( i=0; i < numfiles; ++i) {
struct direntry* file = filelist_file(sfile->files, i);
- if (file && (file->flags & ACTIVEFILE)) {
- file->flags &= ~ACTIVEFILE;
+ if (file && (file->flags & value)) {
+ file->flags &= ~value;
}
}
}
typedef enum FileSelect { FILE_SELECT_DIR = 1,
- FILE_SELECT_FILE = 2 } FileSelect;
+ FILE_SELECT_FILE = 2,
+ FILE_SELECT_NO_UPDATE = 3
+} FileSelect;
+int static arraycomp(int * arrayone, int * arraytwo, int size)
+{
+ int * end = arrayone+size;
+ for(; arrayone < end; arrayone++, arraytwo++)
+ if (*arrayone != *arraytwo) return 0;
+ return 1;
+}
+int static arraycopy(int * newarray, int * oldarray, int size)
+{
+ int * end = newarray+size;
+ for(; newarray < end; newarray++, oldarray++)
+ *newarray = *oldarray;
+ return 1;
+}
+
static void clamp_to_filelist(int numfiles, int *first_file, int *last_file)
{
/* border select before the first file */
@@ -122,31 +139,41 @@
}
}
-static FileSelect file_select(bContext* C, const rcti* rect, short selecting, short toggle_one, short fill)
+static FileSelect file_select(bContext* C, const rcti* rect, short selecting, short toggle_one, short fill, int activetype)
{
ARegion *ar= CTX_wm_region(C);
SpaceFile *sfile= CTX_wm_space_file(C);
int first_file = -1;
int last_file = -1;
int act_file;
+ int oldpoints[6];
FileSelect retval = FILE_SELECT_FILE;
FileSelectParams *params = ED_fileselect_get_params(sfile);
// FileLayout *layout = ED_fileselect_get_layout(sfile, ar);
+ int * point=params->selectarea;
int numfiles = filelist_numfiles(sfile->files);
+ if(activetype==SELECTINGFILE)
+ arraycopy(oldpoints,point, 6);
+
params->selstate = NOTACTIVEFILE;
- first_file = find_file_mouse(sfile, ar, 1, rect->xmin, rect->ymax);
- last_file = find_file_mouse(sfile, ar, 1, rect->xmax, rect->ymin);
+ point[0] = first_file = find_file_mouse(sfile, ar, selecting, rect->xmin, rect->ymax);
+ point[3] = last_file = find_file_mouse(sfile, ar, selecting, rect->xmax, rect->ymin);
+ if(activetype==SELECTINGFILE && arraycomp(point,oldpoints,6))
+ return FILE_SELECT_NO_UPDATE;
+
+ file_deselect_all(sfile,SELECTINGFILE);
+
clamp_to_filelist(numfiles, &first_file, &last_file);
if (fill && (last_file >= 0) && (last_file < numfiles) ) {
int f= last_file;
while (f >= 0) {
struct direntry* file = filelist_file(sfile->files, f);
- if (file->flags & ACTIVEFILE)
+ if (file->flags & activetype)
break;
f--;
}
@@ -161,15 +188,15 @@
struct direntry* file = filelist_file(sfile->files, act_file);
if (toggle_one) {
- if (file->flags & ACTIVEFILE) {
- file->flags &= ~ACTIVEFILE;
+ if (file->flags & activetype) {
+ file->flags &= ~activetype;
selecting=0;
} else
- file->flags |= ACTIVEFILE;
+ file->flags |= activetype;
} else if (selecting)
- file->flags |= ACTIVEFILE;
+ file->flags |= activetype;
else
- file->flags &= ~ACTIVEFILE;
+ file->flags &= ~activetype;
}
}
@@ -181,7 +208,7 @@
struct direntry* file = filelist_file(sfile->files, last_file);
params->active_file = last_file;
- if(file && S_ISDIR(file->type)) {
+ if(file && S_ISDIR(file->type) && activetype != SELECTINGFILE) {
/* the path is too long and we are not going up! */
if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX )
{
@@ -231,7 +258,7 @@
BLI_isect_rcti(&(ar->v2d.mask), &rect, &rect);
- if (FILE_SELECT_DIR == file_select(C, &rect, selecting, 0, 0)) {
+ if (FILE_SELECT_DIR == file_select(C, &rect, selecting, 0, 0, ACTIVEFILE)) {
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
} else {
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
@@ -239,6 +266,26 @@
return OPERATOR_FINISHED;
}
+static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+ wmGesture *gesture= op->customdata;
+ ARegion *ar= CTX_wm_region(C);
+ rcti *rect= gesture->customdata;
+ rcti locrect;
+
+ int result= WM_border_select_modal(C, op, event);
+
+ if(result==OPERATOR_RUNNING_MODAL) {
+ BLI_norm_rcti(&locrect, rect);
+ BLI_isect_rcti(&(ar->v2d.mask), &locrect, &locrect);
+
+ if(FILE_SELECT_NO_UPDATE != file_select(C, &locrect, 1, 0, 0,SELECTINGFILE))
+ WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
+ };
+
+ return result;
+}
+
void FILE_OT_select_border(wmOperatorType *ot)
{
/* identifiers */
@@ -249,7 +296,7 @@
/* 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 */
@@ -276,9 +323,9 @@
return OPERATOR_CANCELLED;
/* single select, deselect all selected first */
- if (!extend) file_deselect_all(sfile);
+ if (!extend) file_deselect_all(sfile,ACTIVEFILE);
- if (FILE_SELECT_DIR == file_select(C, &rect, 1, extend, fill ))
+ if (FILE_SELECT_DIR == file_select(C, &rect, 1, extend, fill, ACTIVEFILE ))
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
else
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL);
Index: source/blender/editors/space_file/filesel.c
===================================================================
--- source/blender/editors/space_file/filesel.c (revision 33459)
+++ source/blender/editors/space_file/filesel.c (working copy)
@@ -614,4 +614,6 @@
sfile->files= NULL;
}
+ if(sfile->params)
+ sfile->params->title[0]=0;
}
Index: source/blender/makesdna/DNA_space_types.h
===================================================================
--- source/blender/makesdna/DNA_space_types.h (revision 33459)
+++ source/blender/makesdna/DNA_space_types.h (working copy)
@@ -185,6 +185,9 @@
int active_file;
int selstate;
+ int selectarea[6];
+ short thumbnail_size;
+ short pad1;
/* short */
/* XXX --- still unused -- */
@@ -718,6 +721,7 @@
#define BTXFILE (1<<12)
#define COLLADAFILE (1<<13)
#define OPERATORFILE (1<<14) /* from filter_glob operator property */
+#define SELECTINGFILE (1<<15)
/* SpaceImage->dt_uv */
#define SI_UVDT_OUTLINE 0
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e8/db/b10ebb34411f10f42dc53681937a
Event Timeline
Log In to Comment