diff options
Diffstat (limited to 'source/blender/editors/space_outliner/outliner_select.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_select.c | 229 |
1 files changed, 116 insertions, 113 deletions
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 8270d26d974..e64804b6090 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -159,11 +159,11 @@ static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeSto Scene *sce; /* paranoia check */ - if(te->idcode!=ID_SCE) + if (te->idcode!=ID_SCE) return 0; sce= (Scene *)tselem->id; - if(set) { + if (set) { sce->r.actlay= tselem->nr; WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); } @@ -181,25 +181,25 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops Object *ob= NULL; /* if id is not object, we search back */ - if(te->idcode==ID_OB) ob= (Object *)tselem->id; + if (te->idcode==ID_OB) ob= (Object *)tselem->id; else { ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==OBACT) return 0; + if (ob==OBACT) return 0; } - if(ob==NULL) return 0; + if (ob==NULL) return 0; sce= (Scene *)outliner_search_back(soops, te, ID_SCE); - if(sce && scene != sce) { + if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } /* find associated base in current scene */ base= object_in_scene(ob, scene); - if(base) { - if(set==2) { + if (base) { + if (set==2) { /* swap select */ - if(base->flag & SELECT) + if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); else ED_base_object_select(base, BA_SELECT); @@ -209,13 +209,13 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops scene_deselect_all(scene); ED_base_object_select(base, BA_SELECT); } - if(C) { + if (C) { ED_base_object_activate(C, base); /* adds notifier */ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } } - if(ob!=scene->obedit) + if (ob!=scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); return 1; @@ -229,32 +229,32 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so /* we search for the object parent */ ob= (Object *)outliner_search_back(soops, te, ID_OB); // note: ob->matbits can be NULL when a local object points to a library mesh. - if(ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia + if (ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia /* searching in ob mat array? */ tes= te->parent; - if(tes->idcode==ID_OB) { - if(set) { + if (tes->idcode==ID_OB) { + if (set) { ob->actcol= te->index+1; ob->matbits[te->index]= 1; // make ob material active too } else { - if(ob->actcol == te->index+1) - if(ob->matbits[te->index]) return 1; + if (ob->actcol == te->index+1) + if (ob->matbits[te->index]) return 1; } } /* or we search for obdata material */ else { - if(set) { + if (set) { ob->actcol= te->index+1; ob->matbits[te->index]= 0; // make obdata material active too } else { - if(ob->actcol == te->index+1) - if(ob->matbits[te->index]==0) return 1; + if (ob->actcol == te->index+1) + if (ob->matbits[te->index]==0) return 1; } } - if(set) { + if (set) { WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); } return 0; @@ -267,7 +267,7 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo Object *ob=OBACT; SpaceButs *sbuts=NULL; - if(ob==NULL) return 0; // no active object + if (ob==NULL) return 0; // no active object /*tselem= TREESTORE(te);*/ /*UNUSED*/ @@ -278,25 +278,25 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo tep= te->parent; tselemp= TREESTORE(tep); - if(tep->idcode==ID_WO) { + if (tep->idcode==ID_WO) { World *wrld= (World *)tselemp->id; - if(set) { - if(sbuts) { + if (set) { + if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture wrld->texact= te->index; } - else if(tselemp->id == (ID *)(scene->world)) { - if(wrld->texact==te->index) return 1; + else if (tselemp->id == (ID *)(scene->world)) { + if (wrld->texact==te->index) return 1; } } - else if(tep->idcode==ID_LA) { + else if (tep->idcode==ID_LA) { Lamp *la= (Lamp *)tselemp->id; - if(set) { - if(sbuts) { + if (set) { + if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 2; } @@ -304,15 +304,15 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo la->texact= te->index; } else { - if(tselemp->id == ob->data) { - if(la->texact==te->index) return 1; + if (tselemp->id == ob->data) { + if (la->texact==te->index) return 1; } } } - else if(tep->idcode==ID_MA) { + else if (tep->idcode==ID_MA) { Material *ma= (Material *)tselemp->id; - if(set) { - if(sbuts) { + if (set) { + if (sbuts) { //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 0; } @@ -322,12 +322,12 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo /* also set active material */ ob->actcol= tep->index+1; } - else if(tep->flag & TE_ACTIVE) { // this is active material - if(ma->texact==te->index) return 1; + else if (tep->flag & TE_ACTIVE) { // this is active material + if (ma->texact==te->index) return 1; } } - if(set) + if (set) WM_event_add_notifier(C, NC_TEXTURE, NULL); return 0; @@ -340,9 +340,9 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops /* we search for the object parent */ ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==NULL || ob!=OBACT) return 0; // just paranoia + if (ob==NULL || ob!=OBACT) return 0; // just paranoia - if(set) { + if (set) { // XXX extern_set_butspace(F5KEY, 0); } else return 1; @@ -354,7 +354,7 @@ static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOo { Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(set) + if (set) return 0; return scene->camera == ob; @@ -367,19 +367,19 @@ static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops Scene *sce=NULL; tep= te->parent; - if(tep) { + if (tep) { tselem= TREESTORE(tep); sce= (Scene *)tselem->id; } - if(set) { // make new scene active - if(sce && scene != sce) { + if (set) { // make new scene active + if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } } - if(tep==NULL || tselem->id == (ID *)scene) { - if(set) { + if (tep==NULL || tselem->id == (ID *)scene) { + if (set) { // XXX extern_set_butspace(F8KEY, 0); } else { @@ -395,7 +395,7 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * /* id in tselem is object */ ob= (Object *)tselem->id; - if(set) { + if (set) { BLI_assert(te->index+1 >= 0); ob->actdef= te->index+1; @@ -403,8 +403,8 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); } else { - if(ob==OBACT) - if(ob->actdef== te->index+1) return 1; + if (ob==OBACT) + if (ob->actdef== te->index+1) return 1; } return 0; } @@ -413,14 +413,14 @@ static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement { Object *ob= (Object *)tselem->id; - if(set) { + if (set) { if (ob->pose) { ob->pose->active_group= te->index+1; WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); } } else { - if(ob==OBACT && ob->pose) { + if (ob==OBACT && ob->pose) { if (ob->pose->active_group== te->index+1) return 1; } } @@ -433,15 +433,16 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen bArmature *arm= ob->data; bPoseChannel *pchan= te->directdata; - if(set) { - if(!(pchan->bone->flag & BONE_HIDDEN_P)) { + if (set) { + if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + if (set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag else ED_pose_deselectall(ob, 0); // 0 = deselect - if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { + if (set==2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; - } else { + } + else { pchan->bone->flag |= BONE_SELECTED; arm->act_bone= pchan->bone; } @@ -451,7 +452,7 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen } } else { - if(ob==OBACT && ob->pose) { + if (ob==OBACT && ob->pose) { if (pchan->bone->flag & BONE_SELECTED) return 1; } } @@ -463,14 +464,15 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, bArmature *arm= (bArmature *)tselem->id; Bone *bone= te->directdata; - if(set) { - if(!(bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + if (set) { + if (!(bone->flag & BONE_HIDDEN_P)) { + if (set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag else ED_pose_deselectall(OBACT, 0); - if(set==2 && (bone->flag & BONE_SELECTED)) { + if (set==2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; - } else { + } + else { bone->flag |= BONE_SELECTED; arm->act_bone= bone; } @@ -481,7 +483,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, else { Object *ob= OBACT; - if(ob && ob->data==arm) { + if (ob && ob->data==arm) { if (bone->flag & BONE_SELECTED) return 1; } } @@ -492,16 +494,16 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, /* ebones only draw in editmode armature */ static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) { - if(sel) { + if (sel) { ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; arm->act_edbone= ebone; // flush to parent? - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; } else { ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); // flush to parent? - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; } WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); @@ -511,16 +513,16 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, bArmature *arm= scene->obedit->data; EditBone *ebone= te->directdata; - if(set==1) { - if(!(ebone->flag & BONE_HIDDEN_A)) { + if (set==1) { + if (!(ebone->flag & BONE_HIDDEN_A)) { ED_armature_deselect_all(scene->obedit, 0); // deselect tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } } else if (set==2) { - if(!(ebone->flag & BONE_HIDDEN_A)) { - if(!(ebone->flag & BONE_SELECTED)) { + if (!(ebone->flag & BONE_HIDDEN_A)) { + if (!(ebone->flag & BONE_SELECTED)) { tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } @@ -539,7 +541,7 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - if(set) { + if (set) { Object *ob= (Object *)tselem->id; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -552,7 +554,7 @@ static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), Tr static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - if(set) { + if (set) { Object *ob= (Object *)tselem->id; WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); @@ -565,7 +567,7 @@ static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeEleme static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - if(set) { + if (set) { Object *ob= (Object *)tselem->id; WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); @@ -586,17 +588,17 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS Object *ob= (Object *)tselem->id; Base *base= object_in_scene(ob, scene); - if(set) { - if(scene->obedit) + if (set) { + if (scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - if(ob->mode & OB_MODE_POSE) + if (ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); } else { - if(ob->mode & OB_MODE_POSE) return 1; + if (ob->mode & OB_MODE_POSE) return 1; } return 0; } @@ -605,11 +607,11 @@ static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(t { Sequence *seq= (Sequence*) te->directdata; - if(set) { + if (set) { // XXX select_single_seq(seq, 1); } else { - if(seq->flag & SELECT) + if (seq->flag & SELECT) return(1); } return(0); @@ -621,8 +623,8 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS Editing *ed= seq_give_editing(scene, FALSE); seq= (Sequence*)te->directdata; - if(set==0) { - if(seq->flag & SELECT) + if (set==0) { + if (seq->flag & SELECT) return(1); return(0); } @@ -630,12 +632,12 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS // XXX select_single_seq(seq, 1); p= ed->seqbasep->first; while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { p= p->next; continue; } -// if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) +// if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); p= p->next; } @@ -646,8 +648,8 @@ static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, { wmKeyMapItem *kmi = te->directdata; - if(set==0) { - if(kmi->flag & KMI_INACTIVE) return 0; + if (set==0) { + if (kmi->flag & KMI_INACTIVE) return 0; return 1; } else { @@ -695,8 +697,8 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl case TSE_MODIFIER: return tree_element_active_modifier(C, te, tselem, set); case TSE_LINKED_OB: - if(set) tree_element_set_active_object(C, scene, soops, te, set); - else if(tselem->id==(ID *)OBACT) return 1; + if (set) tree_element_set_active_object(C, scene, soops, te, set); + else if (tselem->id==(ID *)OBACT) return 1; break; case TSE_LINKED_PSYS: return tree_element_active_psys(C, scene, te, tselem, set); @@ -726,24 +728,24 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) { - if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) { TreeStoreElem *tselem= TREESTORE(te); int openclose= 0; /* open close icon */ - if((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close - if( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) + if ((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close + if ( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) openclose= 1; } - if(openclose) { + if (openclose) { /* all below close/open? */ - if(extend) { + if (extend) { tselem->flag &= ~TSE_CLOSED; outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); } else { - if(tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; + if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } @@ -751,50 +753,51 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa return 1; } /* name and first icon */ - else if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { + else if (mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) { /* always makes active object */ - if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) + if (tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); - if(tselem->type==0) { // the lib blocks + if (tselem->type==0) { // the lib blocks /* editmode? */ - if(te->idcode==ID_SCE) { - if(scene!=(Scene *)tselem->id) { + if (te->idcode==ID_SCE) { + if (scene!=(Scene *)tselem->id) { ED_screen_set_scene(C, CTX_wm_screen(C), (Scene *)tselem->id); } } - else if(te->idcode==ID_GR) { + else if (te->idcode==ID_GR) { Group *gr= (Group *)tselem->id; GroupObject *gob; - if(extend) { + if (extend) { int sel= BA_SELECT; - for(gob= gr->gobject.first; gob; gob= gob->next) { - if(gob->ob->flag & SELECT) { + for (gob= gr->gobject.first; gob; gob= gob->next) { + if (gob->ob->flag & SELECT) { sel= BA_DESELECT; break; } } - for(gob= gr->gobject.first; gob; gob= gob->next) { + for (gob= gr->gobject.first; gob; gob= gob->next) { ED_base_object_select(object_in_scene(gob->ob, scene), sel); } } else { scene_deselect_all(scene); - for(gob= gr->gobject.first; gob; gob= gob->next) { - if((gob->ob->flag & SELECT) == 0) + for (gob= gr->gobject.first; gob; gob= gob->next) { + if ((gob->ob->flag & SELECT) == 0) ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); } } WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } - else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { + else if (ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); - } else { // rest of types + } + else { // rest of types tree_element_active(C, scene, soops, te, 1); } @@ -805,8 +808,8 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa } } - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; + for (te= te->subtree.first; te; te= te->next) { + if (do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; } return 0; } @@ -830,11 +833,11 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; + for (te= soops->tree.first; te; te= te->next) { + if (do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } - if(te) { + if (te) { ED_undo_push(C, "Outliner click event"); } else { @@ -846,7 +849,7 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) fmval[0], fmval[1], NULL, &row); /* select relevant row */ - if(outliner_select(soops, &soops->tree, &row, &selecting)) { + if (outliner_select(soops, &soops->tree, &row, &selecting)) { soops->storeflag |= SO_TREESTORE_REDRAW; @@ -917,7 +920,7 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - for(te= soops->tree.first; te; te= te->next) { + for (te= soops->tree.first; te; te= te->next) { outliner_item_border_select(scene, soops, &rectf, te, gesture_mode); } |