[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [10962] branches/imgbrowser-elubie/source/ blender: === imagebrowser ===
Andrea Weikert
elubie at gmx.net
Mon Jun 18 22:48:56 CEST 2007
Revision: 10962
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=10962
Author: elubie
Date: 2007-06-18 22:48:56 +0200 (Mon, 18 Jun 2007)
Log Message:
-----------
=== imagebrowser ===
- added filtering functions and buttons in the imagebrowser header for filtering.
Currently leftmost of the filtering buttons (the one with '.*' enables filtering, the rest of the buttons determine which file types are shown.
- fix: on 'Load Library' the directory could still contain 'untitled.blend' which wouldn't show anything in the image browser.
- fix: after Link/Append the SpaceImasel type was not set correctly
- fix: added opening image browser to file menu in info window
Modified Paths:
--------------
branches/imgbrowser-elubie/source/blender/include/BIF_filelist.h
branches/imgbrowser-elubie/source/blender/include/blendef.h
branches/imgbrowser-elubie/source/blender/makesdna/DNA_space_types.h
branches/imgbrowser-elubie/source/blender/src/drawimasel.c
branches/imgbrowser-elubie/source/blender/src/editimasel.c
branches/imgbrowser-elubie/source/blender/src/filelist.c
branches/imgbrowser-elubie/source/blender/src/header_imasel.c
branches/imgbrowser-elubie/source/blender/src/header_info.c
branches/imgbrowser-elubie/source/blender/src/space.c
Modified: branches/imgbrowser-elubie/source/blender/include/BIF_filelist.h
===================================================================
--- branches/imgbrowser-elubie/source/blender/include/BIF_filelist.h 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/include/BIF_filelist.h 2007-06-18 20:48:56 UTC (rev 10962)
@@ -53,7 +53,8 @@
void BIF_filelist_appenddir(struct FileList* filelist, const char *relname);
struct direntry * BIF_filelist_file(struct FileList* filelist, int index);
void BIF_filelist_hidedot(struct FileList* filelist, short hide);
-
+void BIF_filelist_setfilter(struct FileList* filelist, unsigned int filter);
+void BIF_filelist_filter(struct FileList* filelist);
void BIF_filelist_swapselect(struct FileList* filelist);
void BIF_filelist_imgsize(struct FileList* filelist, short w, short h);
void BIF_filelist_loadimage(struct FileList* filelist, int index);
Modified: branches/imgbrowser-elubie/source/blender/include/blendef.h
===================================================================
--- branches/imgbrowser-elubie/source/blender/include/blendef.h 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/include/blendef.h 2007-06-18 20:48:56 UTC (rev 10962)
@@ -349,6 +349,7 @@
/* in imasel.h - not any more - elubie */
#define B_SORTIMASELLIST 451
#define B_RELOADIMASELDIR 452
+#define B_FILTERIMASELDIR 453
/* TEXT: 500 */
#define B_TEXTBROWSE 501
Modified: branches/imgbrowser-elubie/source/blender/makesdna/DNA_space_types.h
===================================================================
--- branches/imgbrowser-elubie/source/blender/makesdna/DNA_space_types.h 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/makesdna/DNA_space_types.h 2007-06-18 20:48:56 UTC (rev 10962)
@@ -369,6 +369,11 @@
short ipotype;
+ short filter;
+ short pad;
+ short pad1;
+ short pad2;
+
/* view settings */
short prv_w;
short prv_h;
@@ -417,6 +422,7 @@
#define FILE_ACTIVELAY 32
#define FILE_ATCURSOR 64
#define FILE_SYNCPOSE 128
+#define FILE_FILTER 256
/* sfile->sort */
#define FILE_SORTALPHA 0
@@ -435,8 +441,8 @@
#define SOUNDFILE 256
#define TEXTFILE 512
#define MOVIEFILE_ICON 1024 /* movie file that preview can't load */
+#define FOLDERFILE 2048 /* represents folders for filtering */
-
#define SCROLLH 16 /* height scrollbar */
#define SCROLLB 16 /* width scrollbar */
Modified: branches/imgbrowser-elubie/source/blender/src/drawimasel.c
===================================================================
--- branches/imgbrowser-elubie/source/blender/src/drawimasel.c 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/src/drawimasel.c 2007-06-18 20:48:56 UTC (rev 10962)
@@ -196,7 +196,14 @@
if (BIF_filelist_empty(files))
{
+ unsigned int filter = 0;
BIF_filelist_hidedot(simasel->files, simasel->flag & FILE_HIDE_DOT);
+ if (simasel->flag & FILE_FILTER) {
+ filter = simasel->filter ;
+ } else {
+ filter = 0;
+ }
+ BIF_filelist_setfilter(simasel->files, filter);
BIF_filelist_readdir(files, BIF_filelist_dir(files) );
if(simasel->sort!=FILE_SORTALPHA) BIF_filelist_sort(simasel->files, simasel->sort);
Modified: branches/imgbrowser-elubie/source/blender/src/editimasel.c
===================================================================
--- branches/imgbrowser-elubie/source/blender/src/editimasel.c 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/src/editimasel.c 2007-06-18 20:48:56 UTC (rev 10962)
@@ -218,6 +218,8 @@
}
else {
BLI_split_dirfile(file, temp, name);
+ BLI_strncpy(simasel->dir, temp, sizeof(simasel->dir));
+ BIF_filelist_setdir(simasel->files, simasel->dir);
BIF_filelist_free(simasel->files);
BIF_filelist_freelib(simasel->files);
BIF_filelist_settype(simasel->files, type);
Modified: branches/imgbrowser-elubie/source/blender/src/filelist.c
===================================================================
--- branches/imgbrowser-elubie/source/blender/src/filelist.c 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/src/filelist.c 2007-06-18 20:48:56 UTC (rev 10962)
@@ -90,7 +90,10 @@
typedef struct FileList
{
struct direntry *filelist;
+ struct direntry *unfiltered;
+
int numfiles;
+ int numunfiltered;
char dir[FILE_MAXDIR];
short type;
short ipotype;
@@ -99,6 +102,7 @@
short prv_w;
short prv_h;
short hide_dot;
+ unsigned int filter;
} FileList;
int BIF_groupname_to_code(char *group)
@@ -257,6 +261,64 @@
return (BLI_strcasecmp(sufix1, sufix2));
}
+void BIF_filelist_filter(FileList* filelist)
+{
+ int num_files = 0;
+ int num_filtered = 0;
+ struct direntry *old_filelist;
+ int i, j;
+
+ if (!filelist->filelist)
+ return;
+
+ if (!filelist->filter) {
+ if (filelist->unfiltered) {
+ old_filelist = filelist->filelist;
+ filelist->filelist = filelist->unfiltered;
+ filelist->numfiles = filelist->numunfiltered;
+ filelist->unfiltered = 0;
+ filelist->numunfiltered = 0;
+ free (old_filelist);
+ }
+ return;
+ }
+
+ if (!filelist->unfiltered) {
+ filelist->unfiltered = filelist->filelist;
+ filelist->numunfiltered = filelist->numfiles;
+ }
+
+ old_filelist = filelist->unfiltered;
+ num_files = filelist->numunfiltered;
+
+ filelist->filelist = 0;
+
+ // How many files are left after filter ?
+ for (i = 0; i < num_files; ++i) {
+ if (old_filelist[i].type & S_IFDIR) {
+ if (filelist->filter & FOLDERFILE) {
+ num_filtered++;
+ }
+ }
+ else if (old_filelist[i].flags & filelist->filter) {
+ num_filtered++;
+ }
+ }
+
+ filelist->filelist = (struct direntry *)malloc(num_filtered * sizeof(struct direntry));
+ filelist->numfiles = num_filtered;
+
+ for (i = 0, j=0; i < num_files; ++i) {
+ if (old_filelist[i].type & S_IFDIR) {
+ if (filelist->filter & FOLDERFILE) {
+ filelist->filelist[j++] = old_filelist[i];
+ }
+ } else if (old_filelist[i].flags & filelist->filter) {
+ filelist->filelist[j++] = old_filelist[i];
+ }
+ }
+}
+
void BIF_filelist_init_icons()
{
short x, y, k;
@@ -299,6 +361,7 @@
p->libfiledata = 0;
p->type = 0;
p->has_func = 0;
+ p->filter = 0;
return p;
}
@@ -306,6 +369,8 @@
{
FileList* p = BIF_filelist_new();
BLI_strncpy(p->dir, filelist->dir, FILE_MAXDIR);
+ p->filelist = NULL;
+ p->unfiltered = NULL;
p->type = filelist->type;
p->ipotype = filelist->ipotype;
p->has_func = filelist->has_func;
@@ -321,6 +386,16 @@
printf("Attemtping to delete empty filelist.\n");
return;
}
+
+ if (filelist->unfiltered) {
+ struct direntry* filtered_files = filelist->filelist;
+ filelist->filelist = filelist->unfiltered;
+ filelist->numfiles = filelist->numunfiltered;
+ filelist->numunfiltered = 0;
+ free (filtered_files);
+ filelist->unfiltered = 0;
+ }
+
for (i = 0; i < filelist->numfiles; ++i) {
if (filelist->filelist[i].image)
IMB_freeImBuf(filelist->filelist[i].image);
@@ -331,10 +406,10 @@
if (filelist->filelist[i].string)
MEM_freeN(filelist->filelist[i].string);
filelist->filelist[i].string = 0;
-
}
-
+
filelist->numfiles = 0;
+ free(filelist->filelist);
filelist->filelist = 0;
}
@@ -405,7 +480,7 @@
starttime = PIL_check_seconds_timer();
anim = IMB_open_anim(filelist->filelist[index].relname, IB_rect);
- if (anim == NULL) return(0);
+ if (anim == NULL) return;
opentime = PIL_check_seconds_timer();
imb = IMB_anim_absolute(anim, 0);
@@ -501,13 +576,18 @@
filelist->hide_dot = hide;
}
+void BIF_filelist_setfilter(struct FileList* filelist, unsigned int filter)
+{
+ filelist->filter = filter;
+}
+
void BIF_filelist_readdir(struct FileList* filelist, const char* dir)
{
char wdir[FILE_MAXDIR];
int finished = 0;
if (!filelist) return;
-
+ filelist->unfiltered = 0;
filelist->filelist = 0;
if(filelist->type==FILE_MAIN) {
@@ -530,6 +610,8 @@
chdir(wdir);
BIF_filelist_setfiletypes(filelist, G.have_quicktime);
+ BIF_filelist_filter(filelist);
+
}
}
Modified: branches/imgbrowser-elubie/source/blender/src/header_imasel.c
===================================================================
--- branches/imgbrowser-elubie/source/blender/src/header_imasel.c 2007-06-18 20:22:08 UTC (rev 10961)
+++ branches/imgbrowser-elubie/source/blender/src/header_imasel.c 2007-06-18 20:48:56 UTC (rev 10962)
@@ -82,6 +82,17 @@
BIF_filelist_free(simasel->files);
scrarea_queue_winredraw(curarea);
break;
+ case B_FILTERIMASELDIR:
+ if (simasel->flag & FILE_FILTER) {
+ BIF_filelist_setfilter(simasel->files,simasel->filter);
+ BIF_filelist_filter(simasel->files);
+ scrarea_queue_winredraw(curarea);
+ } else {
+ BIF_filelist_setfilter(simasel->files,0);
+ BIF_filelist_filter(simasel->files);
+ scrarea_queue_winredraw(curarea);
+ }
+ break;
}
}
@@ -132,9 +143,21 @@
xco+= 100;
}
uiBlockBeginAlign(block);
- uiDefIconButBitS(block, TOG, FILE_HIDE_DOT, B_RELOADIMASELDIR, ICON_GHOST,xco+=XIC,0,XIC,YIC, &simasel->flag, 0, 0, 0, 0, "Hides dot files");
+ uiDefIconButBitS(block, TOG, FILE_HIDE_DOT, B_RELOADIMASELDIR, ICON_GHOST,xco+=XIC,0,XIC,YIC, &simasel->flag, 0, 0, 0, 0, "Hides dot files");
uiBlockEndAlign(block);
-
+ xco+=20;
+ uiBlockBeginAlign(block);
+ uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_SORTBYEXT,xco+=XIC,0,XIC,YIC, &simasel->flag, 0, 0, 0, 0, "Filter files");
+ uiDefIconButBitS(block, TOG, IMAGEFILE, B_FILTERIMASELDIR, ICON_IMAGE_COL,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter images");
+ uiDefIconButBitS(block, TOG, BLENDERFILE, B_FILTERIMASELDIR, ICON_BLENDER,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter .blend files");
+ uiDefIconButBitS(block, TOG, MOVIEFILE, B_FILTERIMASELDIR, ICON_SEQUENCE,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter movies");
+ uiDefIconButBitS(block, TOG, PYSCRIPTFILE, B_FILTERIMASELDIR, ICON_PYTHON,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter python scripts");
+ uiDefIconButBitS(block, TOG, FTFONTFILE, B_FILTERIMASELDIR, ICON_SYNTAX,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter fonts");
+ uiDefIconButBitS(block, TOG, SOUNDFILE, B_FILTERIMASELDIR, ICON_SOUND,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter soudn files");
+ uiDefIconButBitS(block, TOG, TEXTFILE, B_FILTERIMASELDIR, ICON_TEXT,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Filter text files");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list