Hide .file blocks in databrowse/pop menu.

This is mainly useful for scripts that generate/load datablocks for their own use and don't want to burry the user under an avalanche of datablocks he/she doesn't care about.

This adds a user pref "Hide .data" which now acts as a default value when opening a new fileselector.
It is also used when creating data select pop menus.

The "ghost" button in a fileselect window is independant from the userpref. It can be turned on/off individually without affecting

Note: When turning the option on/off, it sometimes take a couple of times before the pop menu registers it. Probably some caching thing. Will have to look at it.

Default value is Off.
This commit is contained in:
2005-07-11 23:49:06 +00:00
parent 0c0205ad78
commit 1b466f7765
4 changed files with 52 additions and 32 deletions

View File

@@ -70,6 +70,7 @@
#include "DNA_group_types.h" #include "DNA_group_types.h"
#include "DNA_armature_types.h" #include "DNA_armature_types.h"
#include "DNA_action_types.h" #include "DNA_action_types.h"
#include "DNA_userdef_types.h"
#include "BLI_blenlib.h" #include "BLI_blenlib.h"
#include "BLI_dynstr.h" #include "BLI_dynstr.h"
@@ -559,6 +560,9 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
char buf[32]; char buf[32];
if (nr && id==link) *nr= i+1; if (nr && id==link) *nr= i+1;
if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
continue;
get_flags_for_id(id, buf); get_flags_for_id(id, buf);
@@ -601,6 +605,9 @@ static void IPOnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, sho
if (id==link) if (id==link)
*nr= i+1; *nr= i+1;
if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
continue;
get_flags_for_id(id, buf); get_flags_for_id(id, buf);
BLI_dynstr_append(pupds, buf); BLI_dynstr_append(pupds, buf);

View File

@@ -202,6 +202,7 @@ extern UserDef U; /* from usiblender.c !!!! */
#define USER_LOCKAROUND 4096 #define USER_LOCKAROUND 4096
#define USER_GLOBALUNDO 8192 #define USER_GLOBALUNDO 8192
#define USER_ORBIT_SELECTION 16384 #define USER_ORBIT_SELECTION 16384
#define USER_HIDE_DOT 65536
/* transopts */ /* transopts */

View File

@@ -1097,7 +1097,6 @@ static void draw_filetext(SpaceFile *sfile)
for(a= sfile->ofs; a<sfile->totfile; a++, files++) { for(a= sfile->ofs; a<sfile->totfile; a++, files++) {
if( calc_filesel_line(sfile, a, &x, &y)==0 ) break; if( calc_filesel_line(sfile, a, &x, &y)==0 ) break;
print_line(sfile, files, x, y); print_line(sfile, files, x, y);
} }
@@ -1275,6 +1274,9 @@ void activate_fileselect(int type, char *title, char *file, void (*func)(char *)
if(BLI_convertstringcode(name, G.sce, G.scene->r.cfra)) sfile->flag |= FILE_STRINGCODE; if(BLI_convertstringcode(name, G.sce, G.scene->r.cfra)) sfile->flag |= FILE_STRINGCODE;
else sfile->flag &= ~FILE_STRINGCODE; else sfile->flag &= ~FILE_STRINGCODE;
if (U.uiflag & USER_HIDE_DOT)
sfile->flag |= FILE_HIDE_DOT;
if(type==FILE_MAIN) { if(type==FILE_MAIN) {
char *groupname; char *groupname;
@@ -2372,6 +2374,10 @@ void main_to_filelist(SpaceFile *sfile)
struct direntry *files, *firstlib = NULL; struct direntry *files, *firstlib = NULL;
ListBase *lb; ListBase *lb;
int a, fake, idcode, len, ok, totlib, totbl; int a, fake, idcode, len, ok, totlib, totbl;
short hide = 0;
if (sfile->flag & FILE_HIDE_DOT)
hide = 1;
if(sfile->dir[0]=='/') sfile->dir[0]= 0; if(sfile->dir[0]=='/') sfile->dir[0]= 0;
@@ -2425,12 +2431,12 @@ void main_to_filelist(SpaceFile *sfile)
id= lb->first; id= lb->first;
sfile->totfile= 0; sfile->totfile= 0;
while(id) { while(id) {
if(sfile->returnfunc && idcode==ID_IP) { if(sfile->returnfunc && idcode==ID_IP) {
if(sfile->ipotype== ((Ipo *)id)->blocktype) sfile->totfile++; if(sfile->ipotype== ((Ipo *)id)->blocktype) sfile->totfile++;
} }
else sfile->totfile++; else if (hide==0 || id->name[2] != '.')
sfile->totfile++;
id= id->next; id= id->next;
} }
@@ -2463,33 +2469,35 @@ void main_to_filelist(SpaceFile *sfile)
if(ok) { if(ok) {
memset( files, 0 , sizeof(struct direntry)); if (hide==0 || id->name[2] != '.') {
files->relname= BLI_strdup(id->name+2); memset( files, 0 , sizeof(struct direntry));
files->relname= BLI_strdup(id->name+2);
if(sfile->returnfunc==0) { /* F4 DATA BROWSE */
if(idcode==ID_OB) { if(sfile->returnfunc==0) { /* F4 DATA BROWSE */
if( ((Object *)id)->flag & SELECT) files->flags |= ACTIVE; if(idcode==ID_OB) {
if( ((Object *)id)->flag & SELECT) files->flags |= ACTIVE;
}
else if(idcode==ID_SCE) {
if( ((Scene *)id)->r.scemode & R_BG_RENDER) files->flags |= ACTIVE;
}
} }
else if(idcode==ID_SCE) { files->nr= totbl+1;
if( ((Scene *)id)->r.scemode & R_BG_RENDER) files->flags |= ACTIVE; files->poin= id;
fake= id->flag & LIB_FAKEUSER;
if(id->lib && fake) sprintf(files->extra, "LF %d", id->us);
else if(id->lib) sprintf(files->extra, "L %d", id->us);
else if(fake) sprintf(files->extra, "F %d", id->us);
else sprintf(files->extra, " %d", id->us);
if(id->lib) {
if(totlib==0) firstlib= files;
totlib++;
} }
files++;
totbl++;
} }
files->nr= totbl+1;
files->poin= id;
fake= id->flag & LIB_FAKEUSER;
if(id->lib && fake) sprintf(files->extra, "LF %d", id->us);
else if(id->lib) sprintf(files->extra, "L %d", id->us);
else if(fake) sprintf(files->extra, "F %d", id->us);
else sprintf(files->extra, " %d", id->us);
if(id->lib) {
if(totlib==0) firstlib= files;
totlib++;
}
files++;
totbl++;
} }
id= id->next; id= id->next;

View File

@@ -1087,7 +1087,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
else if(val==3) v3d->twmode= V3D_MANIP_NORMAL; else if(val==3) v3d->twmode= V3D_MANIP_NORMAL;
v3d->twflag |= V3D_USE_MANIPULATOR; v3d->twflag |= V3D_USE_MANIPULATOR;
doredraw= 1; doredraw= 1;
} }
} }
break; break;
@@ -2850,17 +2850,21 @@ void drawinfospace(ScrArea *sa, void *spacedata)
uiDefBut(block, LABEL,0,"System:", uiDefBut(block, LABEL,0,"System:",
(xpos+edgsp+(4*midsp)+(4*mpref)),y3label,mpref,buth, (xpos+edgsp+(4*midsp)+(4*mpref)),y4label,mpref,buth,
0, 0, 0, 0, 0, ""); 0, 0, 0, 0, 0, "");
uiDefButBitI(block, TOG, USER_DISABLE_SOUND, B_SOUNDTOGGLE, "Disable Game Sound", uiDefButBitI(block, TOG, USER_DISABLE_SOUND, B_SOUNDTOGGLE, "Disable Game Sound",
(xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth, (xpos+edgsp+(4*mpref)+(4*midsp)),y3,mpref,buth,
&(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played in games"); &(U.gameflags), 0, 0, 0, 0, "Disables sounds from being played in games");
uiDefButBitI(block, TOG, USER_FILTERFILEEXTS, 0, "Filter File Extensions", uiDefButBitI(block, TOG, USER_FILTERFILEEXTS, 0, "Filter File Extensions",
(xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth, (xpos+edgsp+(4*mpref)+(4*midsp)),y2,mpref,buth,
&(U.uiflag), 0, 0, 0, 0, "Display only files with extensions in the image select window"); &(U.uiflag), 0, 0, 0, 0, "Display only files with extensions in the image select window");
uiDefButBitI(block, TOG, USER_HIDE_DOT, 0, "Hide dot file/datablock",
(xpos+edgsp+(4*mpref)+(4*midsp)),y1,mpref,buth,
&(U.uiflag), 0, 0, 0, 0, "Hide files/datablocks that start with a dot(.*)");
uiDefBut(block, LABEL,0,"OpenGL:", uiDefBut(block, LABEL,0,"OpenGL:",
(xpos+edgsp+(5*midsp)+(5*mpref)),y5label,mpref,buth, (xpos+edgsp+(5*midsp)+(5*mpref)),y5label,mpref,buth,