Support more kinds of paths for path re-writing / traversing, patch from Alex Fraser...
[blender.git] / source / blender / editors / space_outliner / outliner_draw.c
index 67d0e68..96b5548 100644 (file)
@@ -66,6 +66,8 @@
 #include "BKE_scene.h"
 #include "BKE_sequencer.h"
 
+#include "BLI_ghash.h"
+
 #include "ED_armature.h"
 #include "ED_object.h"
 #include "ED_screen.h"
@@ -95,7 +97,7 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h)
        TreeElement *te= lb->first;
        while(te) {
                TreeStoreElem *tselem= TREESTORE(te);
-               if((tselem->flag & TSE_CLOSED)==0) 
+               if(TSELEM_OPEN(tselem,soops))
                        outliner_height(soops, &te->subtree, h);
                (*h) += UI_UNIT_Y;
                te= te->next;
@@ -110,7 +112,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w)
 //             TreeStoreElem *tselem= TREESTORE(te);
                
                // XXX fixme... te->xend is not set yet
-               if(tselem->flag & TSE_CLOSED) {
+               if(!TSELEM_OPEN(tselem,soops)) {
                        if (te->xend > *w)
                                *w = te->xend;
                }
@@ -133,7 +135,7 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start
                if(startx+100 > *w)
                        *w = startx+100;
 
-               if((tselem->flag & TSE_CLOSED)==0)
+               if(TSELEM_OPEN(tselem,soops))
                        outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X);
                te= te->next;
        }
@@ -234,7 +236,7 @@ static int group_select_flag(Group *gr)
        return 0;
 }
 
-static void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
+void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag)
 {      
        Scene *scene = (Scene *)poin;           
        GroupObject *gob;
@@ -308,11 +310,15 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname)
                        }                                       
                        /* Check the library target exists */
                        if (te->idcode == ID_LI) {
-                               char expanded[FILE_MAXDIR + FILE_MAXFILE];
-                               BLI_strncpy(expanded, ((Library *)tselem->id)->name, FILE_MAXDIR + FILE_MAXFILE);
+                               Library *lib= (Library *)tselem->id;
+                               char expanded[FILE_MAX];
+
+                               BKE_library_filepath_set(lib, lib->name);
+
+                               BLI_strncpy(expanded, lib->name, sizeof(expanded));
                                BLI_path_abs(expanded, G.main->name);
                                if (!BLI_exists(expanded)) {
-                                       BKE_report(CTX_wm_reports(C), RPT_ERROR, "This path does not exist, correct this before saving");
+                                       BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Library path '%s' does not exist, correct this before saving", expanded);
                                }
                        }
                }
@@ -517,7 +523,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                        }
                }
                
-               if((tselem->flag & TSE_CLOSED)==0) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree);
+               if(TSELEM_OPEN(tselem,soops)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree);
        }
 }
 
@@ -558,7 +564,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
                                ptr= &te->rnaptr;
                                prop= te->directdata;
                                
-                               if(!(RNA_property_type(prop) == PROP_POINTER && (tselem->flag & TSE_CLOSED)==0))
+                               if(!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem,soops))) )
                                        uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1);
                        }
                        else if(tselem->type == TSE_RNA_ARRAY_ELEM) {
@@ -569,7 +575,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa
                        }
                }
                
-               if((tselem->flag & TSE_CLOSED)==0) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree);
+               if(TSELEM_OPEN(tselem,soops)) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree);
        }
 }
 
@@ -584,9 +590,10 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar
 
 static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items)
 {
-       wmOperatorType *ot = WM_operatortype_first();
-       
-       for(; ot; ot= ot->next) {
+       GHashIterator *iter= WM_operatortype_iter();
+
+       for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+               wmOperatorType *ot= BLI_ghashIterator_getValue(iter);
                
                if(BLI_strcasestr(ot->idname, str)) {
                        char name[OP_MAX_TYPENAME];
@@ -598,6 +605,7 @@ static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(ar
                                break;
                }
        }
+       BLI_ghashIterator_free(iter);
 }
 
 /* operator Search browse menu, open */
@@ -824,7 +832,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo
                        }
                }
                
-               if((tselem->flag & TSE_CLOSED)==0) outliner_draw_keymapbuts(block, ar, soops, &te->subtree);
+               if(TSELEM_OPEN(tselem,soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree);
        }
 }
 
@@ -867,7 +875,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa
                        }
                }
                
-               if((tselem->flag & TSE_CLOSED)==0) outliner_buttons(C, block, ar, soops, &te->subtree);
+               if(TSELEM_OPEN(tselem,soops)) outliner_buttons(C, block, ar, soops, &te->subtree);
        }
 }
 
@@ -1004,6 +1012,10 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto
                                                UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break;
                                        case eModifierType_Screw:
                                                UI_icon_draw(x, y, ICON_MOD_SCREW); break;
+                                       case eModifierType_WeightVGEdit:
+                                       case eModifierType_WeightVGMix:
+                                       case eModifierType_WeightVGProximity:
+                                               UI_icon_draw(x, y, ICON_MOD_VERTEX_WEIGHT); break;
                                        default:
                                                UI_icon_draw(x, y, ICON_DOT); break;
                                }
@@ -1178,7 +1190,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa
                        if(active) {
                                float ufac= UI_UNIT_X/20.0f;
 
-                               uiSetRoundBox(15);
+                               uiSetRoundBox(UI_CNR_ALL);
                                glColor4ub(255, 255, 255, 100);
                                uiRoundBox( (float)*offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac);
                                glEnable(GL_BLEND); /* roundbox disables */
@@ -1233,6 +1245,18 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                
                glEnable(GL_BLEND);
 
+               /* start by highlighting search matches 
+                *      we don't expand items when searching in the datablocks but we 
+                *      still want to highlight any filter matches. 
+                */
+               if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && 
+                        (tselem->flag & TSE_SEARCHMATCH)) 
+               {
+                       /* TODO - add search highlight color to theme? */
+                       glColor4f(0.2f, 0.5f, 0.2f, 0.3f);
+                       glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1);
+               }
+
                /* colors for active/selected data */
                if(tselem->type==0) {
                        if(te->idcode==ID_SCE) {
@@ -1297,7 +1321,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                
                /* active circle */
                if(active) {
-                       uiSetRoundBox(15);
+                       uiSetRoundBox(UI_CNR_ALL);
                        uiRoundBox( (float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac);
                        glEnable(GL_BLEND);     /* roundbox disables it */
                        
@@ -1313,10 +1337,10 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                                icon_x = startx+5*ufac;
                        
                                // icons a bit higher
-                       if(tselem->flag & TSE_CLOSED) 
-                               UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT);
-                       else
+                       if(TSELEM_OPEN(tselem,soops)) 
                                UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN);
+                       else
+                               UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT);
                }
                offsx+= UI_UNIT_X;
                
@@ -1352,7 +1376,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
                offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name));
                
                /* closed item, we draw the icons, not when it's a scene, or master-server list though */
-               if(tselem->flag & TSE_CLOSED) {
+               if(!TSELEM_OPEN(tselem,soops)) {
                        if(te->subtree.first) {
                                if(tselem->type==0 && te->idcode==ID_SCE);
                                else if(tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so dont draw */
@@ -1378,7 +1402,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene
        te->ys= (float)*starty;
        te->xend= startx+offsx;
                
-       if((tselem->flag & TSE_CLOSED)==0) {
+       if(TSELEM_OPEN(tselem,soops)) {
                *starty-= UI_UNIT_Y;
                
                for(ten= te->subtree.first; ten; ten= ten->next)
@@ -1411,7 +1435,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
                        
                *starty-= UI_UNIT_Y;
                
-               if((tselem->flag & TSE_CLOSED)==0)
+               if(TSELEM_OPEN(tselem,soops))
                        outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty);
        }
        
@@ -1435,12 +1459,12 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase *
                tselem= TREESTORE(te);
                
                /* selection status */
-               if((tselem->flag & TSE_CLOSED)==0)
+               if(TSELEM_OPEN(tselem,soops))
                        if(tselem->type == TSE_RNA_STRUCT)
                                glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1);
 
                *starty-= UI_UNIT_Y;
-               if((tselem->flag & TSE_CLOSED)==0) {
+               if(TSELEM_OPEN(tselem,soops)) {
                        outliner_draw_struct_marks(ar, soops, &te->subtree, starty);
                        if(tselem->type == TSE_RNA_STRUCT)
                                fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y);
@@ -1461,7 +1485,7 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb,
                        glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1);
                }
                *starty-= UI_UNIT_Y;
-               if((tselem->flag & TSE_CLOSED)==0) outliner_draw_selection(ar, soops, &te->subtree, starty);
+               if(TSELEM_OPEN(tselem,soops)) outliner_draw_selection(ar, soops, &te->subtree, starty);
        }
 }