Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Weikert <elubie@gmx.net>2011-03-20 14:16:59 +0300
committerAndrea Weikert <elubie@gmx.net>2011-03-20 14:16:59 +0300
commite73a2020dd1450a709d8da53af9132e08c811226 (patch)
tree7930fd4934a75472cc10db8e312f25d20c641fa0 /source/blender/editors/space_file
parent5325f3b2e989a3b94e2d9450c574e4610d2005d8 (diff)
== filebrowser == Code cleanup
* Separate out selection flags from file type flags, was bothering me since forever ;) * Also renamed ACTIVEFILE to SELECTED_FILE to better reflect actual usage in code. * Fix crash introduced with last commit, better check for valid selection
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c14
-rw-r--r--source/blender/editors/space_file/file_ops.c38
-rw-r--r--source/blender/editors/space_file/filelist.c16
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/editors/space_file/space_file.c2
5 files changed, 38 insertions, 34 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 68651674bd5..c8f4dc26e90 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -514,10 +514,10 @@ void file_draw_list(const bContext *C, ARegion *ar)
UI_ThemeColor4(TH_TEXT);
- if (!(file->flags & EDITING)) {
- 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;
+ if (!(file->selflag & EDITING_FILE)) {
+ if ((params->active_file == i) || (file->selflag & HILITED_FILE) || (file->selflag & SELECTED_FILE) ) {
+ int colorid = (file->selflag & SELECTED_FILE) ? TH_HILITE : TH_BACK;
+ int shade = (params->active_file == i) || (file->selflag & HILITED_FILE) ? 20 : 0;
draw_tile(sx, sy-1, layout->tile_w+4, sfile->layout->tile_h+layout->tile_border_y, colorid, shade);
}
}
@@ -539,17 +539,17 @@ void file_draw_list(const bContext *C, ARegion *ar)
UI_ThemeColor4(TH_TEXT);
- if (file->flags & EDITING) {
+ if (file->selflag & EDITING_FILE) {
uiBut *but = uiDefBut(block, TEX, 1, "", sx , sy-layout->tile_h-3,
textwidth, textheight, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit),0,0,"");
uiButSetRenameFunc(but, renamebutton_cb, file);
uiButSetFlag(but, UI_BUT_NO_UTF8); /* allow non utf8 names */
if ( 0 == uiButActiveOnly(C, block, but)) {
- file->flags &= ~EDITING;
+ file->selflag &= ~EDITING_FILE;
}
}
- if (!(file->flags & EDITING)) {
+ if (!(file->selflag & EDITING_FILE)) {
int tpos = (FILE_IMGDISPLAY == params->display) ? sy - layout->tile_h + layout->textheight : sy;
file_draw_string(sx+1, tpos, file->relname, textwidth, textheight, align);
}
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index f36bb6f030d..f0d4b2df8d3 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -96,8 +96,8 @@ static void file_deselect_all(SpaceFile* sfile, unsigned int flag)
for ( i=0; i < numfiles; ++i) {
struct direntry* file = filelist_file(sfile->files, i);
- if (file && (file->flags & flag)) {
- file->flags &= ~flag;
+ if (file && (file->selflag & flag)) {
+ file->selflag &= ~flag;
}
}
}
@@ -151,7 +151,7 @@ static FileSelection file_selection_get(bContext* C, const rcti* rect, short fil
int f= sel.last;
while (f >= 0) {
struct direntry* file = filelist_file(sfile->files, f);
- if (file->flags & ACTIVEFILE)
+ if (file->selflag & SELECTED_FILE)
break;
f--;
}
@@ -213,15 +213,19 @@ static FileSelect file_select(bContext* C, const rcti* rect, FileSelType select,
struct direntry *file;
/* flag the files as selected in the filelist */
- filelist_select(sfile->files, &sel, select, ACTIVEFILE);
+ filelist_select(sfile->files, &sel, select, SELECTED_FILE);
/* Don't act on multiple selected files */
if (sel.first != sel.last) select = 0;
- /* Check last selection, if selected, act on the file or dir */
- file = filelist_file(sfile->files, sel.last);
- if (file->flags & ACTIVEFILE) {
- retval = file_select_do(C, sel.last);
+ /* Do we have a valid selection and are we actually selecting */
+ if ( (sel.last >= 0) && ((select == FILE_SEL_ADD) || (select == FILE_SEL_TOGGLE)) )
+ {
+ /* Check last selection, if selected, act on the file or dir */
+ file = filelist_file(sfile->files, sel.last);
+ if (file && (file->selflag & SELECTED_FILE)) {
+ retval = file_select_do(C, sel.last);
+ }
}
/* update operator for name change event */
@@ -328,7 +332,7 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
return OPERATOR_CANCELLED;
/* single select, deselect all selected first */
- if (!extend) file_deselect_all(sfile, ACTIVEFILE);
+ if (!extend) file_deselect_all(sfile, SELECTED_FILE);
ret = file_select(C, &rect, extend ? FILE_SEL_TOGGLE : FILE_SEL_ADD, fill);
if (FILE_SELECT_DIR == ret)
@@ -369,8 +373,8 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
/* if any file is selected, deselect all first */
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->selflag & SELECTED_FILE)) {
+ file->selflag &= ~SELECTED_FILE;
select = 0;
ED_area_tag_redraw(sa);
}
@@ -380,7 +384,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op))
for ( i=0; i < numfiles; ++i) {
struct direntry* file = filelist_file(sfile->files, i);
if(file && !S_ISDIR(file->type)) {
- file->flags |= ACTIVEFILE;
+ file->selflag |= SELECTED_FILE;
ED_area_tag_redraw(sa);
}
}
@@ -627,7 +631,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
if(RNA_struct_find_property(op->ptr, "files")) {
for (i=0; i<numfiles; i++) {
file = filelist_file(sfile->files, i);
- if(file->flags & ACTIVEFILE) {
+ if(file->selflag & SELECTED_FILE) {
if ((file->type & S_IFDIR)==0) {
RNA_collection_add(op->ptr, "files", &itemptr);
RNA_string_set(&itemptr, "name", file->relname);
@@ -639,7 +643,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
if(RNA_struct_find_property(op->ptr, "dirs")) {
for (i=0; i<numfiles; i++) {
file = filelist_file(sfile->files, i);
- if(file->flags & ACTIVEFILE) {
+ if(file->selflag & SELECTED_FILE) {
if ((file->type & S_IFDIR)) {
RNA_collection_add(op->ptr, "dirs", &itemptr);
RNA_string_set(&itemptr, "name", file->relname);
@@ -728,7 +732,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
for (i=0; i<filelist_numfiles(sfile->files); i++) {
file = filelist_file(sfile->files, i);
- if(file->flags & ACTIVEFILE) {
+ if(file->selflag & SELECTED_FILE) {
active=1;
}
}
@@ -893,7 +897,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent
for (i=0; i < numfiles; ++i)
{
struct direntry *file = filelist_file(sfile->files, i);
- if (file->flags & EDITING) {
+ if (file->selflag & EDITING_FILE) {
edit_idx=i;
break;
}
@@ -1296,7 +1300,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op))
int numfiles = filelist_numfiles(sfile->files);
if ( (0<=idx) && (idx<numfiles) ) {
struct direntry *file= filelist_file(sfile->files, idx);
- file->flags |= EDITING;
+ file->selflag |= EDITING_FILE;
BLI_strncpy(sfile->params->renameedit, file->relname, FILE_MAXFILE);
sfile->params->renamefile[0]= '\0';
}
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 3c76b815a80..649c2dadc0c 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -914,15 +914,15 @@ void filelist_swapselect(struct FileList* filelist)
file= filelist->filelist;
for(num=0; num<filelist->numfiles; num++, file++) {
- if(file->flags & ACTIVEFILE) {
+ if(file->selflag & SELECTED_FILE) {
act= 1;
break;
}
}
file= filelist->filelist+2;
for(num=2; num<filelist->numfiles; num++, file++) {
- if(act) file->flags &= ~ACTIVEFILE;
- else file->flags |= ACTIVEFILE;
+ if(act) file->selflag &= ~SELECTED_FILE;
+ else file->selflag |= SELECTED_FILE;
}
}
@@ -936,13 +936,13 @@ void filelist_select(struct FileList* filelist, FileSelection* sel, FileSelType
switch (select) {
case FILE_SEL_REMOVE:
- file->flags &= ~flag;
+ file->selflag &= ~flag;
break;
case FILE_SEL_ADD:
- file->flags |= flag;
+ file->selflag |= flag;
break;
case FILE_SEL_TOGGLE:
- file->flags ^= flag;
+ file->selflag ^= flag;
break;
}
}
@@ -1183,10 +1183,10 @@ void filelist_from_main(struct FileList *filelist)
#if 0 // XXXXX TODO show the selection status of the objects
if(!filelist->has_func) { /* F4 DATA BROWSE */
if(idcode==ID_OB) {
- if( ((Object *)id)->flag & SELECT) files->flags |= ACTIVEFILE;
+ if( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE;
}
else if(idcode==ID_SCE) {
- if( ((Scene *)id)->r.scemode & R_BG_RENDER) files->flags |= ACTIVEFILE;
+ if( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE;
}
}
#endif
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 305598e7a0b..22f15b76dd3 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -568,7 +568,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern)
for (i = 0; i < n; i++) {
file = filelist_file(sfile->files, i);
if (fnmatch(pattern, file->relname, 0) == 0) {
- file->flags |= ACTIVEFILE;
+ file->selflag |= SELECTED_FILE;
match = 1;
}
}
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index d4240a9ad53..ec0d9806bca 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -236,7 +236,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa))
if (idx >= 0) {
struct direntry *file= filelist_file(sfile->files, idx);
if (file) {
- file->flags |= EDITING;
+ file->selflag |= EDITING_FILE;
}
}
BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit));