== imagebrowser ==
authorAndrea Weikert <elubie@gmx.net>
Tue, 2 Oct 2007 09:11:50 +0000 (09:11 +0000)
committerAndrea Weikert <elubie@gmx.net>
Tue, 2 Oct 2007 09:11:50 +0000 (09:11 +0000)
- activated image browser for texture databrowse (texture buttons)
- activated image browser for brush texture databrowse (+small fix of callback function)
- activated image browser for image databrowse in UV/image editor
- fixed: filter didn't work with databrowse and append/link.
- filter buttons in header now don't appear when doing databrowse or append/link
- loading previews for textures added when linking/appending.

source/blender/blenloader/intern/readblenentry.c
source/blender/src/buttons_editing.c
source/blender/src/editimasel.c
source/blender/src/filelist.c
source/blender/src/header_image.c
source/blender/src/header_imasel.c
source/blender/src/headerbuttons.c
source/blender/src/interface_icons.c

index dfa06ebdeb8465b7289a7afadcd3f18c351d9833..ef287428a198aad909fdee134f55939bd7ab5565 100644 (file)
@@ -233,7 +233,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype)
        for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) {
                if (bhead->code==ofblocktype) {
                        ID *id= (ID*) (bhead+1);
-                       if (GS(id->name) == ID_MA) {
+                       if ( (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
                                new_prv = MEM_callocN(sizeof(PreviewImage), "newpreview");
                                BLI_linklist_prepend(&previews, new_prv);
                                looking = 1;
index e7c96586732bfd8d7ec098d55d76a4bf7f5b7f39..8fdb9626603cd87520a9471e0ee78e63417fb19e 100644 (file)
@@ -5064,7 +5064,11 @@ void do_fpaintbuts(unsigned short event)
                        if(G.buts->menunr==-2) {
                                MTex *mtex= brush->mtex[brush->texact];
                                ID *id= (ID*)((mtex)? mtex->tex: NULL);
-                               activate_databrowse(id, ID_TE, 0, B_BTEXBROWSE, &G.buts->menunr, do_global_buttons);
+                               if(G.qual & LR_CTRLKEY) {
+                                       activate_databrowse_imasel(id, ID_TE, 0, B_BTEXBROWSE, &G.buts->menunr, do_fpaintbuts);
+                               } else {
+                                       activate_databrowse(id, ID_TE, 0, B_BTEXBROWSE, &G.buts->menunr, do_fpaintbuts);
+                               }
                                break;
                        }
                        else if(G.buts->menunr < 0) break;
index c2058bf96fd56ce008d952dc5e4489b14fa97116..ed5465e938f81c05b942adb21000df02ccea9314 100644 (file)
@@ -619,7 +619,7 @@ static void do_imasel_buttons(short event, SpaceImaSel *simasel)
                        simasel->file[0] = '\0';                        
                        simasel->scrollpos = 0;
                        simasel->active_file = -1;
-                       scrarea_queue_winredraw(curarea);
+                       scrarea_queue_redraw(curarea);
                }
 
                simasel->active_file = -1;
@@ -632,7 +632,7 @@ static void do_imasel_buttons(short event, SpaceImaSel *simasel)
                simasel->file[0] = '\0';
                simasel->active_file = -1;
                simasel->scrollpos = 0;
-               scrarea_queue_winredraw(curarea);
+               scrarea_queue_redraw(curarea);
        }
        else if(event== B_FS_LOAD) {
                if(simasel->type) 
@@ -812,6 +812,7 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
        char str[FILE_MAXDIR+FILE_MAXFILE+12];
        short mval[2];
        short do_draw = 0;
+       short do_headdraw = 0;
        int numfiles;
        struct direntry *file;
        float scrollstep = 0;
@@ -931,6 +932,7 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                simasel->active_file = -1;
                                                simasel->scrollpos = 0;
                                                do_draw = 1;
+                                               do_headdraw = 1;
                                                
                                        }
                                        else if (file)
@@ -972,7 +974,7 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                                                simasel->file[0] = '\0';                        
                                                                simasel->scrollpos = 0;
                                                                simasel->active_file = -1;
-                                                               scrarea_queue_winredraw(curarea);
+                                                               do_headdraw = 1;
                                                        }
                                                }
                                        } else {
@@ -1054,6 +1056,7 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                simasel->file[0] = '\0';
                                simasel->active_file = -1;
                                simasel->scrollpos = 0;
+                               do_headdraw = 1;
                        }
                        do_draw = 1;    
                        break;
@@ -1089,7 +1092,10 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                /* XXX, stupid patch, curarea can become undone
                 * because of file loading... fixme zr
                 */
-       if(do_draw && curarea) scrarea_queue_winredraw(curarea);
+       if(curarea) {
+               if(do_draw) scrarea_queue_winredraw(curarea);
+               if(do_headdraw) scrarea_queue_headredraw(curarea);
+       }
 }
 
 
index 23a5e73f7cdc4c63dedb6f3ccb0a16e76d4d829c..54fab06f8114a5a7a99fd693e216ae9e17be50ea 100644 (file)
@@ -265,12 +265,18 @@ static int compare_extension(const void *a1, const void *a2) {
 
 void BIF_filelist_filter(FileList* filelist)
 {
+       char dir[FILE_MAX], group[GROUP_MAX];
        int num_filtered = 0;
        int i, j;
-
+       
        if (!filelist->filelist)
                return;
        
+       if ( ( (filelist->type == FILE_LOADLIB) &&  BIF_filelist_islibrary(filelist, dir, group)) 
+               || (filelist->type == FILE_MAIN) ) {
+               filelist->filter = 0;
+       }
+
        if (!filelist->filter) {
                if (filelist->fidx) {
                        MEM_freeN(filelist->fidx);
@@ -912,6 +918,9 @@ void BIF_filelist_from_library(struct FileList* filelist)
        BIF_filelist_sort(filelist, FILE_SORTALPHA);
 
        BLI_strncpy(G.sce, filename, sizeof(filename)); // prevent G.sce to change
+
+       filelist->filter = 0;
+       BIF_filelist_filter(filelist);
 }
 
 void BIF_filelist_append_library(struct FileList *filelist, char *dir, char *file, short flag, int idcode)
@@ -1066,6 +1075,8 @@ void BIF_filelist_from_main(struct FileList *filelist)
                        qsort(firstlib, totlib, sizeof(struct direntry), compare_name);
                }
        }
+       filelist->filter = 0;
+       BIF_filelist_filter(filelist);
 }
 
 
index 86a53ba2b3d311944706753a49c55cf386a2336a..be33e5e2a00c5efcae7894db3b69c1f08633c966 100644 (file)
@@ -117,8 +117,13 @@ void do_image_buttons(unsigned short event)
 
        case B_SIMABROWSE:      
                if(G.sima->imanr== -2) {
-                       activate_databrowse((ID *)G.sima->image, ID_IM, 0, B_SIMABROWSE,
+                       if(G.qual & LR_CTRLKEY) {
+                               activate_databrowse_imasel((ID *)G.sima->image, ID_IM, 0, B_SIMABROWSE,
                                                                                        &G.sima->imanr, do_image_buttons);
+                       } else {
+                               activate_databrowse((ID *)G.sima->image, ID_IM, 0, B_SIMABROWSE,
+                                                                                       &G.sima->imanr, do_image_buttons);
+                       }
                        return;
                }
                if(G.sima->imanr < 0) break;
@@ -308,7 +313,11 @@ void do_image_buttons(unsigned short event)
                        if(G.sima->menunr==-2) {
                                MTex *mtex= brush->mtex[brush->texact];
                                ID *id= (ID*)((mtex)? mtex->tex: NULL);
-                               activate_databrowse(id, ID_TE, 0, B_SIMABTEXBROWSE, &G.sima->menunr, do_global_buttons);
+                               if(G.qual & LR_CTRLKEY) {
+                                       activate_databrowse_imasel(id, ID_TE, 0, B_SIMABTEXBROWSE, &G.sima->menunr, do_image_buttons);
+                               } else {
+                                       activate_databrowse(id, ID_TE, 0, B_SIMABTEXBROWSE, &G.sima->menunr, do_image_buttons);
+                               }
                                break;
                        }
                        else if(G.sima->menunr < 0) break;
index 1897e5d82f6d4d654345e7b960a94c1d802b601b..1402e8c244e635418a5704d91b29e49c619bb31c 100644 (file)
 #endif
 
 #include "BMF_Api.h"
-#include "BIF_language.h"
+
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_utildefines.h"
 
 #include "DNA_ID.h"
 #include "DNA_screen_types.h"
 #include "BIF_gl.h"
 #include "BIF_imasel.h"
 #include "BIF_interface.h"
+#include "BIF_language.h"
 #include "BIF_resources.h"
 #include "BIF_screen.h"
-#include "BKE_global.h"
-#include "BKE_main.h"
 #include "BSE_headerbuttons.h"
 
 #include "blendef.h"
@@ -102,6 +104,9 @@ void imasel_buttons(void)
        uiBlock *block;
        short xco, xcotitle;
        char naam[256];
+       char dir[FILE_MAXDIR], group[32];
+       short type;
+       int do_filter = 0;
 
        simasel= curarea->spacedata.first;
 
@@ -148,20 +153,28 @@ void imasel_buttons(void)
        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;
-               
-       uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_SORTBYEXT,xco+=XIC,0,XIC,YIC, &simasel->flag, 0, 0, 0, 0, "Filter files");
-       if (simasel->flag & FILE_FILTER) {
-               xco+=4;
-               uiBlockBeginAlign(block);
-               uiDefIconButBitS(block, TOG, IMAGEFILE, B_FILTERIMASELDIR, ICON_IMAGE_COL,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show images");
-               uiDefIconButBitS(block, TOG, BLENDERFILE, B_FILTERIMASELDIR, ICON_BLENDER,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show .blend files");
-               uiDefIconButBitS(block, TOG, MOVIEFILE, B_FILTERIMASELDIR, ICON_SEQUENCE,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show movies");
-               uiDefIconButBitS(block, TOG, PYSCRIPTFILE, B_FILTERIMASELDIR, ICON_PYTHON,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show python scripts");
-               uiDefIconButBitS(block, TOG, FTFONTFILE, B_FILTERIMASELDIR, ICON_SYNTAX,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show fonts");
-               uiDefIconButBitS(block, TOG, SOUNDFILE, B_FILTERIMASELDIR, ICON_SOUND,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show sound files");
-               uiDefIconButBitS(block, TOG, TEXTFILE, B_FILTERIMASELDIR, ICON_TEXT,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show text files");
-               uiDefIconButBitS(block, TOG, FOLDERFILE, B_FILTERIMASELDIR, ICON_FILESEL,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show folders");
-               uiBlockEndAlign(block);
+       
+       type = simasel->type;
+       if (type == FILE_LOADLIB) {
+               do_filter = !BIF_filelist_islibrary(simasel->files, dir, group);
+       } else {
+               do_filter = (type != FILE_MAIN);
+       }
+       if ( do_filter ) {
+               uiDefIconButBitS(block, TOG, FILE_FILTER, B_FILTERIMASELDIR, ICON_SORTBYEXT,xco+=XIC,0,XIC,YIC, &simasel->flag, 0, 0, 0, 0, "Filter files");
+               if (simasel->flag & FILE_FILTER) {
+                       xco+=4;
+                       uiBlockBeginAlign(block);
+                       uiDefIconButBitS(block, TOG, IMAGEFILE, B_FILTERIMASELDIR, ICON_IMAGE_COL,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show images");
+                       uiDefIconButBitS(block, TOG, BLENDERFILE, B_FILTERIMASELDIR, ICON_BLENDER,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show .blend files");
+                       uiDefIconButBitS(block, TOG, MOVIEFILE, B_FILTERIMASELDIR, ICON_SEQUENCE,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show movies");
+                       uiDefIconButBitS(block, TOG, PYSCRIPTFILE, B_FILTERIMASELDIR, ICON_PYTHON,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show python scripts");
+                       uiDefIconButBitS(block, TOG, FTFONTFILE, B_FILTERIMASELDIR, ICON_SYNTAX,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show fonts");
+                       uiDefIconButBitS(block, TOG, SOUNDFILE, B_FILTERIMASELDIR, ICON_SOUND,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show sound files");
+                       uiDefIconButBitS(block, TOG, TEXTFILE, B_FILTERIMASELDIR, ICON_TEXT,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show text files");
+                       uiDefIconButBitS(block, TOG, FOLDERFILE, B_FILTERIMASELDIR, ICON_FILESEL,xco+=XIC,0,XIC,YIC, &simasel->filter, 0, 0, 0, 0, "Show folders");
+                       uiBlockEndAlign(block);
+               }
        }
 
        uiDefButBitS(block, TOG, FILE_STRINGCODE, 0, "Relative Paths", xco+=XIC+20,0,100,YIC, &simasel->flag, 0, 0, 0, 0, "Makes sure returned paths are relative to the current .blend file");
index 617bef705df6011e490ca446fcfb70613b838ae5..f293d627f68648dcc7bad830796c947b1b4597ec 100644 (file)
@@ -859,8 +859,12 @@ void do_global_buttons(unsigned short event)
                                        if(mtex) id= (ID *)mtex->tex;
                                }
                        }
-                       
-                       activate_databrowse(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
+                       if(G.qual & LR_CTRLKEY) {
+                               activate_databrowse_imasel(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
+                       }
+                       else {
+                               activate_databrowse(id, ID_TE, 0, B_TEXBROWSE, &G.buts->texnr, do_global_buttons);
+                       }
                        return;
                }
                if(G.buts->texnr < 0) break;
index 610ad09ca34f94471d272502f5f6ecb6f02367e3..d93834d8d8ae6a5f6e781c522db671746d4eede1 100644 (file)
@@ -1028,7 +1028,7 @@ static void icon_draw_mipmap(float x, float y, int icon_id, float aspect, int mi
                PreviewImage* pi = BKE_previewimg_get((ID*)icon->obj); 
 
                if (pi) {                       
-                       if (!nocreate && pi->changed[miplevel]) /* changed only ever set by dynamic icons */
+                       if (!nocreate && (pi->changed[miplevel] ||!pi->rect[miplevel])) /* changed only ever set by dynamic icons */
                        {
                                waitcursor(1);
                                /* create the preview rect if necessary */