2.5/Posemode:
[blender-staging.git] / source / blender / editors / space_outliner / outliner.c
index 589feac6226ddd76780b54dc8857b14b0615ef48..33119317a6da246d837e834fa7dcba6eeea95e90 100644 (file)
@@ -620,7 +620,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                        
                                        tenla->name= "Pose";
                                        
-                                       if(arm->edbo==NULL && (ob->flag & OB_POSEMODE)) {       // channels undefined in editmode, but we want the 'tenla' pose icon itself
+                                       if(arm->edbo==NULL && (ob->mode & OB_MODE_POSE)) {      // channels undefined in editmode, but we want the 'tenla' pose icon itself
                                                int a= 0, const_index= 1000;    /* ensure unique id for bone constraints */
                                                
                                                for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) {
@@ -887,7 +887,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                                else {
                                        /* do not extend Armature when we have posemode */
                                        tselem= TREESTORE(te->parent);
-                                       if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->flag & OB_POSEMODE);
+                                       if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE);
                                        else {
                                                Bone *curBone;
                                                for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){
@@ -1016,7 +1016,6 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv;
                PropertyRNA *prop, *iterprop;
                PropertyType proptype;
-               PropertySubType propsubtype;
                int a, tot;
 
                /* we do lazy build, for speed and to avoid infinite recusion */
@@ -1096,31 +1095,20 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                        }
                }
                else if(type == TSE_RNA_ARRAY_ELEM) {
-                       /* array property element */
-                       static char *vectoritem[4]= {"  x", "  y", "  z", "  w"};
-                       static char *quatitem[4]= {"  w", "  x", "  y", "  z"};
-                       static char *coloritem[4]= {"  r", "  g", "  b", "  a"};
+                       char c;
 
                        prop= parent->directdata;
-                       proptype= RNA_property_type(prop);
-                       propsubtype= RNA_property_subtype(prop);
-                       tot= RNA_property_array_length(prop);
 
                        te->directdata= prop;
                        te->rnaptr= *ptr;
                        te->index= index;
 
-                       if(tot == 4 && propsubtype == PROP_ROTATION)
-                               te->name= quatitem[index];
-                       else if(tot <= 4 && (propsubtype == PROP_VECTOR || propsubtype == PROP_ROTATION))
-                               te->name= vectoritem[index];
-                       else if(tot <= 4 && propsubtype == PROP_COLOR)
-                               te->name= coloritem[index];
-                       else {
-                               te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName");
-                               sprintf(te->name, "  %d", index+1);
-                               te->flag |= TE_FREE_NAME;
-                       }
+                       c= RNA_property_array_item_char(prop, index);
+
+                       te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName");
+                       if(c) sprintf(te->name, "  %c", c);
+                       else sprintf(te->name, "  %d", index+1);
+                       te->flag |= TE_FREE_NAME;
                }
        }
        else if(type == TSE_KEYMAP) {
@@ -1132,8 +1120,9 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i
                te->name= km->nameid;
                
                if(!(tselem->flag & TSE_CLOSED)) {
+                       a= 0;
                        
-                       for (kmi= km->keymap.first; kmi; kmi= kmi->next) {
+                       for (kmi= km->keymap.first; kmi; kmi= kmi->next, a++) {
                                const char *key= WM_key_event_string(kmi->type);
                                
                                if(key[0]) {
@@ -1489,7 +1478,7 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre
 
 static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
        
@@ -1528,7 +1517,7 @@ static void object_toggle_selectability_cb(bContext *C, Scene *scene, TreeElemen
 
 static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
        
@@ -1567,7 +1556,7 @@ void object_toggle_renderability_cb(bContext *C, Scene *scene, TreeElement *te,
 
 static int outliner_toggle_renderability_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
        
@@ -1596,7 +1585,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot)
 
 static int outliner_toggle_expanded_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
        
        if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1))
@@ -1627,7 +1616,7 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot)
 
 static int outliner_toggle_selected_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
        
        if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1))
@@ -1680,7 +1669,7 @@ static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curleve
 
 static int outliner_one_level_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
        int add= RNA_boolean_get(op->ptr, "open");
        int level;
@@ -2188,13 +2177,13 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *te,
                if(scene->obedit) 
                        ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
                
-               if(ob->flag & OB_POSEMODE) 
+               if(ob->mode & OB_MODE_POSE) 
                        ED_armature_exit_posemode(C, base);
                else 
                        ED_armature_enter_posemode(C, base);
        }
        else {
-               if(ob->flag & OB_POSEMODE) return 1;
+               if(ob->mode & OB_MODE_POSE) return 1;
        }
        return 0;
 }
@@ -2367,7 +2356,7 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event)
 {
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        TreeElement *te;
        float fmval[2];
        int extend= RNA_boolean_get(op->ptr, "extend");
@@ -2447,7 +2436,7 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement
 static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event)
 {
        ARegion *ar= CTX_wm_region(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        TreeElement *te;
        float fmval[2];
        int all= RNA_boolean_get(op->ptr, "all");
@@ -2514,7 +2503,7 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T
 static int outliner_item_rename(bContext *C, wmOperator *op, wmEvent *event)
 {
        ARegion *ar= CTX_wm_region(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        TreeElement *te;
        float fmval[2];
        
@@ -2592,7 +2581,7 @@ static TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id)
 
 static int outliner_show_active_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *so= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *so= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
        View2D *v2d= &ar->v2d;
@@ -2822,7 +2811,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase
 /* show entire object level hierarchy */
 static int outliner_show_hierarchy_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        ARegion *ar= CTX_wm_region(C);
        Scene *scene= CTX_data_scene(C);
        
@@ -3072,10 +3061,6 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto
                if(scene->obedit==base->object) 
                        ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
                
-               if(base==BASACT) {
-                       ED_view3d_exit_paint_modes(C);
-               }
-               
                ED_base_object_free_and_unlink(scene, base);
                te->directdata= NULL;
                tselem->id= NULL;
@@ -3247,7 +3232,7 @@ static EnumPropertyItem prop_object_op_types[] = {
 static int outliner_object_operation_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        int event;
        char *str;
        
@@ -3329,7 +3314,7 @@ static EnumPropertyItem prop_group_op_types[] = {
 static int outliner_group_operation_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        int event;
        
        /* check for invalid states */
@@ -3386,7 +3371,7 @@ static EnumPropertyItem prop_id_op_types[] = {
 static int outliner_id_operation_exec(bContext *C, wmOperator *op)
 {
        Scene *scene= CTX_data_scene(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0;
        int event;
        
@@ -3453,7 +3438,7 @@ static EnumPropertyItem prop_data_op_types[] = {
 
 static int outliner_data_operation_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0;
        int event;
        
@@ -3513,57 +3498,6 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot)
 }
 
 
-/* ****** Drag & Drop ****** */
-
-static int outliner_drag_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       wmWindow *win= CTX_wm_window(C);
-       Object *ob= CTX_data_active_object(C);
-       PointerRNA ptr;
-
-       RNA_pointer_create(NULL, &RNA_Object, ob, &ptr);
-
-       return OPERATOR_RUNNING_MODAL;
-}
-
-static int outliner_drag_modal(bContext *C, wmOperator *op, wmEvent *event)
-{
-       switch(event->type) {
-               case MOUSEDRAG:
-
-                       break;
-               case MOUSEDROP:
-                       return OPERATOR_FINISHED;
-               case ESCKEY:
-                       return OPERATOR_CANCELLED;
-       }
-
-       return OPERATOR_RUNNING_MODAL;
-}
-
-static int outliner_drag_exec(bContext *C, wmOperator *op)
-{
-       return OPERATOR_FINISHED;
-}
-
-void OUTLINER_OT_drag(wmOperatorType *ot)
-{
-       /* identifiers */
-       ot->name= "Drag";
-       ot->idname= "OUTLINER_OT_drag";
-
-       /* api callbacks */
-       ot->invoke= outliner_drag_invoke;
-       ot->modal= outliner_drag_modal;
-       ot->exec= outliner_drag_exec;
-
-       ot->poll= ED_operator_outliner_active;
-
-       /* flags */
-       /* ot->flag= OPTYPE_UNDO; */
-}
-
-
 /* ******************** */
 
 
@@ -3626,7 +3560,7 @@ static int outliner_operation(bContext *C, wmOperator *op, wmEvent *event)
 {
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        TreeElement *te;
        float fmval[2];
        
@@ -3660,7 +3594,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C)
 {
        ScrArea *sa= CTX_wm_area(C);
        if ((sa) && (sa->spacetype==SPACE_OUTLINER)) {
-               SpaceOops *so= (SpaceOops *)CTX_wm_space_data(C);
+               SpaceOops *so= CTX_wm_space_outliner(C);
                return (so->outlinevis == SO_DATABLOCKS);
        }
        return 0;
@@ -3724,7 +3658,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
                                }
                                else if(RNA_property_type(prop) == PROP_COLLECTION) {
                                        char buf[128], *name;
-
+                                       
                                        temnext= (TreeElement*)(ld->next->data);
                                        tsenext= TREESTORE(temnext);
                                        
@@ -3873,7 +3807,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short m
 
 static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soutliner= CTX_wm_space_outliner(C);
        
        /* check for invalid states */
        if (soutliner == NULL)
@@ -3908,7 +3842,7 @@ void OUTLINER_OT_drivers_add(wmOperatorType *ot)
 
 static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soutliner= CTX_wm_space_outliner(C);
        
        /* check for invalid states */
        if (soutliner == NULL)
@@ -4043,7 +3977,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa
 
 static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soutliner= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks= verify_active_keyingset(scene, 1);
        
@@ -4083,7 +4017,7 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot)
 
 static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *op)
 {
-       SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soutliner= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        KeyingSet *ks= verify_active_keyingset(scene, 1);
        
@@ -4228,13 +4162,13 @@ static void tselem_draw_icon(float x, float y, TreeStoreElem *tselem, TreeElemen
                        case TSE_POSEGRP_BASE:
                                UI_icon_draw(x, y, ICON_VERTEXSEL); break;
                        case TSE_SEQUENCE:
-                               if((te->idcode==SEQ_MOVIE) || (te->idcode==SEQ_MOVIE_AND_HD_SOUND))
+                               if(te->idcode==SEQ_MOVIE)
                                        UI_icon_draw(x, y, ICON_SEQUENCE);
                                else if(te->idcode==SEQ_META)
                                        UI_icon_draw(x, y, ICON_DOT);
                                else if(te->idcode==SEQ_SCENE)
                                        UI_icon_draw(x, y, ICON_SCENE);
-                               else if((te->idcode==SEQ_RAM_SOUND) || (te->idcode==SEQ_HD_SOUND))
+                               else if(te->idcode==SEQ_SOUND)
                                        UI_icon_draw(x, y, ICON_SOUND);
                                else if(te->idcode==SEQ_IMAGE)
                                        UI_icon_draw(x, y, ICON_IMAGE_COL);
@@ -4765,7 +4699,7 @@ static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2)
 
 static void namebutton_cb(bContext *C, void *tsep, char *oldname)
 {
-       SpaceOops *soops= (SpaceOops *)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        Scene *scene= CTX_data_scene(C);
        Object *obedit= CTX_data_edit_object(C);
        TreeStore *ts= soops->treestore;
@@ -5294,7 +5228,7 @@ void draw_outliner(const bContext *C)
        Scene *scene= CTX_data_scene(C);
        ARegion *ar= CTX_wm_region(C);
        View2D *v2d= &ar->v2d;
-       SpaceOops *soops= (SpaceOops*)CTX_wm_space_data(C);
+       SpaceOops *soops= CTX_wm_space_outliner(C);
        uiBlock *block;
        int sizey= 0, sizex= 0, sizex_rna= 0;