From 44505b38df557a5711703613685a1dec9fc2c3d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jun 2018 09:31:30 +0200 Subject: Cleanup: strip trailing space in editors --- .../blender/editors/space_outliner/outliner_draw.c | 292 ++++++++--------- .../blender/editors/space_outliner/outliner_edit.c | 352 ++++++++++----------- .../editors/space_outliner/outliner_intern.h | 2 +- .../blender/editors/space_outliner/outliner_ops.c | 34 +- .../editors/space_outliner/outliner_select.c | 126 ++++---- .../editors/space_outliner/outliner_tools.c | 238 +++++++------- .../blender/editors/space_outliner/outliner_tree.c | 286 ++++++++--------- .../editors/space_outliner/space_outliner.c | 44 +-- 8 files changed, 687 insertions(+), 687 deletions(-) (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 58c2deaf6df..0ea69164034 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -102,7 +102,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) TreeElement *te = lb->first; while (te) { // TreeStoreElem *tselem = TREESTORE(te); - + // XXX fixme... te->xend is not set yet if (!TSELEM_OPEN(tselem, soops)) { if (te->xend > *w) @@ -142,7 +142,7 @@ static void restrictbutton_recursive_ebone(bContext *C, EditBone *ebone_parent, Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit->data; EditBone *ebone; - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) { if (set_flag) { @@ -228,12 +228,12 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) { Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - + if (!common_restrict_check(C, ob)) return; - + /* deselect objects that are invisible */ if (ob->restrictflag & OB_RESTRICT_VIEW) { - /* Ouch! There is no backwards pointer from Object to Base, + /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } @@ -251,12 +251,12 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) { Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - + if (!common_restrict_check(C, ob)) return; - + /* if select restriction has just been turned on */ if (ob->restrictflag & OB_RESTRICT_SELECT) { - /* Ouch! There is no backwards pointer from Object to Base, + /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } @@ -290,7 +290,7 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2) static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) { Object *ob = (Object *)poin2; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } @@ -405,7 +405,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) continue; gob->ob->restrictflag &= ~flag; - + if (flag == OB_RESTRICT_VIEW) if (gob->ob->flag & SELECT) ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT); @@ -428,7 +428,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) } } } -} +} static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2) { @@ -450,9 +450,9 @@ static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poi static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void *UNUSED(poin2)) { ID *id = (ID *)poin; - + BLI_assert(id != NULL); - + if (id->flag & LIB_FAKEUSER) { id_us_plus(id); } @@ -470,13 +470,13 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) Object *obedit = CTX_data_edit_object(C); BLI_mempool *ts = soops->treestore; TreeStoreElem *tselem = tsep; - + if (ts && tselem) { TreeElement *te = outliner_find_tree_element(&soops->tree, tselem); - + if (tselem->type == 0) { BLI_libblock_ensure_unique_name(bmain, tselem->id->name); - + switch (GS(tselem->id->name)) { case ID_MA: WM_event_add_notifier(C, NC_MATERIAL, NULL); break; @@ -538,11 +538,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) Bone *bone = te->directdata; Object *ob; char newname[sizeof(bone->name)]; - + /* always make current object active */ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL, true); ob = OBACT; - + /* restore bone name */ BLI_strncpy(newname, bone->name, sizeof(bone->name)); BLI_strncpy(bone->name, oldname, sizeof(bone->name)); @@ -555,13 +555,13 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) bPoseChannel *pchan = te->directdata; Object *ob; char newname[sizeof(pchan->name)]; - + /* always make current pose-bone active */ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL, true); ob = OBACT; BLI_assert(ob->type == OB_ARMATURE); - + /* restore bone name */ BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); @@ -573,7 +573,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) { Object *ob = (Object *)tselem->id; // id = object bActionGroup *grp = te->directdata; - + BLI_uniquename(&ob->pose->agroups, grp, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "Group"), '.', offsetof(bActionGroup, name), sizeof(grp->name)); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -583,7 +583,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) { bGPdata *gpd = (bGPdata *)tselem->id; // id = GP Datablock bGPDlayer *gpl = te->directdata; - + // XXX: name needs translation stuff BLI_uniquename(&gpd->layers, gpl, "GP Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); @@ -599,7 +599,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ +{ uiBut *bt; TreeElement *te; TreeStoreElem *tselem; @@ -632,23 +632,23 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict viewport visibility (Ctrl - Recursive)")); UI_but_func_set(bt, restrictbutton_view_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_SELECT_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, object_prop_hide_select, -1, 0, 0, -1, -1, TIP_("Restrict viewport selection (Ctrl - Recursive)")); UI_but_func_set(bt, restrictbutton_sel_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_RENDER_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, object_prop_hide_render, -1, 0, 0, -1, -1, TIP_("Restrict rendering (Ctrl - Recursive)")); UI_but_func_set(bt, restrictbutton_rend_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + UI_block_emboss_set(block, UI_EMBOSS); - + } if (tselem->type == 0 && te->idcode == ID_GR) { int restrict_bool; @@ -657,7 +657,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar if (ID_IS_LINKED(gr)) but_flag |= UI_BUT_DISABLED; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); @@ -686,28 +686,28 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar /* scene render layers and passes have toggle-able flags too! */ else if (tselem->type == TSE_R_LAYER) { UI_block_emboss_set(block, UI_EMBOSS_NONE); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, te->directdata, 0, 0, 0, 0, TIP_("Render this RenderLayer")); UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + UI_block_emboss_set(block, UI_EMBOSS); } else if (tselem->type == TSE_R_PASS) { int *layflag = te->directdata; int passflag = 1 << tselem->nr; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); - - + + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, passflag, 0, ICON_CHECKBOX_HLT - 1, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, layflag, 0, 0, 0, 0, TIP_("Render this Pass")); UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + layflag++; /* is lay_xor */ if (ELEM(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) @@ -718,13 +718,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } - + UI_block_emboss_set(block, UI_EMBOSS); } else if (tselem->type == TSE_MODIFIER) { ModifierData *md = (ModifierData *)te->directdata; ob = (Object *)tselem->id; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, @@ -732,7 +732,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_modifier_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(md->mode), 0, 0, 0, 0, TIP_("Restrict/Allow renderability")); @@ -745,7 +745,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; ob = (Object *)tselem->id; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, @@ -753,7 +753,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_bone_visibility_cb, ob->data, bone); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0, @@ -765,7 +765,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } else if (tselem->type == TSE_EBONE) { EditBone *ebone = (EditBone *)te->directdata; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, @@ -773,7 +773,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_ebone_visibility_cb, NULL, ebone); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0, @@ -785,29 +785,29 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } else if (tselem->type == TSE_GP_LAYER) { bGPDlayer *gpl = (bGPDlayer *)te->directdata; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); - + bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_HIDE, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_LOCKED, 0, ICON_UNLOCKED, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0, TIP_("Restrict/Allow editing of strokes and keyframes in this layer")); UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + /* TODO: visibility in renders */ - + UI_block_emboss_set(block, UI_EMBOSS); } } - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); } } @@ -846,16 +846,16 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops &id->flag, 0, 0, 0, 0, tip); UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL); UI_but_flag_enable(bt, but_flag); - - + + BLI_str_format_int_grouped(buf, id->us); - bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, + bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Number of users of this data-block")); UI_but_flag_enable(bt, but_flag); - - + + bt = uiDefButBitS(block, UI_BTYPE_TOGGLE, LIB_FAKEUSER, 1, (id->flag & LIB_FAKEUSER) ? "F" : " ", (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, &id->flag, 0, 0, 0, 0, @@ -863,11 +863,11 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops "even if nothing else uses it")); UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL); UI_but_flag_enable(bt, but_flag); - + UI_block_emboss_set(block, UI_EMBOSS); } } - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_userbuts(block, ar, soops, &te->subtree); } } @@ -926,12 +926,12 @@ static void outliner_draw_rnabuts(uiBlock *block, ARegion *ar, SpaceOops *soops, else if (tselem->type == TSE_RNA_ARRAY_ELEM) { ptr = &te->rnaptr; prop = te->directdata; - + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } } - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_rnabuts(block, ar, soops, sizex, &te->subtree); } @@ -995,7 +995,7 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) uiBut *but = uiDefIconBut(arg->block, UI_BTYPE_LABEL, 0, icon, arg->xb, arg->yb, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && ID_IS_LINKED(arg->id)) ? arg->id->lib->name : ""); - + if (arg->id) UI_but_drag_set_id(but, arg->id); } @@ -1019,17 +1019,17 @@ static void UNUSED_FUNCTION(tselem_draw_gp_icon_uibut)(struct DrawIconArg *arg, RNA_pointer_create(id, &RNA_GPencilLayer, gpl, &ptr); UI_block_align_begin(arg->block); - + UI_block_emboss_set(arg->block, is_stroke_visible ? UI_EMBOSS : UI_EMBOSS_NONE); uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb, arg->yb, w, h, &ptr, "color", -1, 0, 0, 0, 0, NULL); - + UI_block_emboss_set(arg->block, is_fill_visible ? UI_EMBOSS : UI_EMBOSS_NONE); uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb + w, arg->yb, w, h, &ptr, "fill_color", -1, 0, 0, 0, 0, NULL); - + UI_block_emboss_set(arg->block, UI_EMBOSS_NONE); UI_block_align_end(arg->block); } @@ -1040,7 +1040,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto { struct DrawIconArg arg; float aspect; - + /* make function calls a bit compacter */ arg.block = block; arg.id = tselem->id; @@ -1048,7 +1048,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto arg.xb = x; /* for ui buttons */ arg.yb = y; arg.alpha = alpha; - + /* placement of icons, copied from interface_widgets.c */ aspect = (0.8f * UI_UNIT_Y) / ICON_DEFAULT_HEIGHT; x += 2.0f * aspect; @@ -1086,29 +1086,29 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto Object *ob = (Object *)tselem->id; ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); switch ((ModifierType)md->type) { - case eModifierType_Subsurf: + case eModifierType_Subsurf: UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; - case eModifierType_Armature: + case eModifierType_Armature: UI_icon_draw(x, y, ICON_MOD_ARMATURE); break; - case eModifierType_Lattice: + case eModifierType_Lattice: UI_icon_draw(x, y, ICON_MOD_LATTICE); break; - case eModifierType_Curve: + case eModifierType_Curve: UI_icon_draw(x, y, ICON_MOD_CURVE); break; - case eModifierType_Build: + case eModifierType_Build: UI_icon_draw(x, y, ICON_MOD_BUILD); break; - case eModifierType_Mirror: + case eModifierType_Mirror: UI_icon_draw(x, y, ICON_MOD_MIRROR); break; - case eModifierType_Decimate: + case eModifierType_Decimate: UI_icon_draw(x, y, ICON_MOD_DECIM); break; - case eModifierType_Wave: + case eModifierType_Wave: UI_icon_draw(x, y, ICON_MOD_WAVE); break; - case eModifierType_Hook: + case eModifierType_Hook: UI_icon_draw(x, y, ICON_HOOK); break; - case eModifierType_Softbody: + case eModifierType_Softbody: UI_icon_draw(x, y, ICON_MOD_SOFT); break; - case eModifierType_Boolean: + case eModifierType_Boolean: UI_icon_draw(x, y, ICON_MOD_BOOLEAN); break; - case eModifierType_ParticleSystem: + case eModifierType_ParticleSystem: UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; case eModifierType_ParticleInstance: UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; @@ -1362,13 +1362,13 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa eOLDrawState active; for (te = lb->first; te; te = te->next) { - + /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) break; tselem = TREESTORE(te); - + /* object hierarchy always, further constrained on level */ if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { @@ -1401,32 +1401,32 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa (float)UI_UNIT_Y / 2.0f - ufac); glEnable(GL_BLEND); /* roundbox disables */ } - + tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); te->xs = *offsx; te->ys = ys; te->xend = (short)*offsx + UI_UNIT_X; te->flag |= TE_ICONROW; // for click - + (*offsx) += UI_UNIT_X; } - + /* this tree element always has same amount of branches, so don't draw */ if (tselem->type != TSE_R_LAYER) outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level + 1, xmax, offsx, ys); } - + } /* closed tree element */ static void outliner_set_coord_tree_element(TreeElement *te, int startx, int starty) { TreeElement *ten; - + /* store coord and continue, we need coordinates for elements outside view too */ te->xs = startx; te->ys = starty; - + for (ten = te->subtree.first; ten; ten = ten->next) { outliner_set_coord_tree_element(ten, startx + UI_UNIT_X, starty); } @@ -1442,13 +1442,13 @@ static void outliner_draw_tree_element( float ufac = UI_UNIT_X / 20.0f; int offsx = 0; eOLDrawState active = OL_DRAWSEL_NONE; - + tselem = TREESTORE(te); if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { int xmax = ar->v2d.cur.xmax; unsigned char alpha = 128; - + if ((tselem->flag & TSE_TEXTBUT) && (*te_edit == NULL)) { *te_edit = te; } @@ -1456,12 +1456,12 @@ static void outliner_draw_tree_element( /* icons can be ui buts, we don't want it to overlap with restrict */ if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) xmax -= OL_TOGW + UI_UNIT_X; - + 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. + /* 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)) @@ -1475,7 +1475,7 @@ static void outliner_draw_tree_element( /* colors for active/selected data */ if (tselem->type == 0) { - + if (te->idcode == ID_SCE) { if (tselem->id == (ID *)scene) { glColor4ub(255, 255, 255, alpha); @@ -1489,35 +1489,35 @@ static void outliner_draw_tree_element( UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); col[3] = alpha; glColor4ubv((GLubyte *)col); - + active = OL_DRAWSEL_ACTIVE; } } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; - + if (ob == OBACT || (ob->flag & SELECT)) { char col[4] = {0, 0, 0, 0}; - + /* outliner active ob: always white text, circle color now similar to view3d */ - + active = OL_DRAWSEL_ACTIVE; if (ob == OBACT) { if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); col[3] = alpha; } - + active = OL_DRAWSEL_NORMAL; } else if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); col[3] = alpha; } - + glColor4ubv((GLubyte *)col); } - + } else if (scene->obedit && scene->obedit->data == tselem->id) { glColor4ub(255, 255, 255, alpha); @@ -1536,7 +1536,7 @@ static void outliner_draw_tree_element( } glColor4ub(220, 220, 255, alpha); } - + /* active circle */ if (active != OL_DRAWSEL_NONE) { UI_draw_roundbox_corner_set(UI_CNR_ALL); @@ -1547,15 +1547,15 @@ static void outliner_draw_tree_element( (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 1.0f * ufac); glEnable(GL_BLEND); /* roundbox disables it */ - + te->flag |= TE_ACTIVE; // for lookup in display hierarchies } - + /* open/close icon, only when sublevels, except for scene */ if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { int icon_x; icon_x = startx; - + // icons a bit higher if (TSELEM_OPEN(tselem, soops)) UI_icon_draw((float)icon_x + 2 * ufac, (float)*starty + 1 * ufac, ICON_DISCLOSURE_TRI_DOWN); @@ -1563,18 +1563,18 @@ static void outliner_draw_tree_element( UI_icon_draw((float)icon_x + 2 * ufac, (float)*starty + 1 * ufac, ICON_DISCLOSURE_TRI_RIGHT); } offsx += UI_UNIT_X; - + /* datatype icon */ - + if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { - + tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, 1.0f); - + offsx += UI_UNIT_X + 2 * ufac; } else offsx += 2 * ufac; - + if (tselem->type == 0 && ID_IS_LINKED(tselem->id)) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); if (tselem->id->tag & LIB_TAG_MISSING) { @@ -1590,7 +1590,7 @@ static void outliner_draw_tree_element( offsx += UI_UNIT_X + 2 * ufac; } glDisable(GL_BLEND); - + /* name */ if ((tselem->flag & TSE_TEXTBUT) == 0) { if (active == OL_DRAWSEL_NORMAL) { @@ -1605,9 +1605,9 @@ static void outliner_draw_tree_element( UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name); } - + offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name)); - + /* closed item, we draw the icons, not when it's a scene, or master-server list though */ if (!TSELEM_OPEN(tselem, soops)) { if (te->subtree.first) { @@ -1618,19 +1618,19 @@ static void outliner_draw_tree_element( /* this tree element always has same amount of branches, so don't draw */ int tempx = startx + offsx; - + /* divider */ UI_ThemeColorShade(TH_BACK, -40); glRecti(tempx - 10.0f * ufac, *starty + 4.0f * ufac, tempx - 8.0f * ufac, *starty + UI_UNIT_Y - 4.0f * ufac); - + glEnable(GL_BLEND); glPixelTransferf(GL_ALPHA_SCALE, 0.5); - + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty); - + glPixelTransferf(GL_ALPHA_SCALE, 1.0); glDisable(GL_BLEND); } @@ -1641,7 +1641,7 @@ static void outliner_draw_tree_element( te->xs = startx; te->ys = *starty; te->xend = startx + offsx; - + if (TSELEM_OPEN(tselem, soops)) { *starty -= UI_UNIT_Y; @@ -1653,7 +1653,7 @@ static void outliner_draw_tree_element( for (ten = te->subtree.first; ten; ten = ten->next) { outliner_set_coord_tree_element(ten, startx, *starty); } - + *starty -= UI_UNIT_Y; } } @@ -1663,30 +1663,30 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeElement *te; TreeStoreElem *tselem; int y1, y2; - + if (BLI_listbase_is_empty(lb)) return; - + y1 = y2 = *starty; /* for vertical lines between objects */ for (te = lb->first; te; te = te->next) { y2 = *starty; tselem = TREESTORE(te); - + /* horizontal line? */ if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) glRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1); - + *starty -= UI_UNIT_Y; - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_hierarchy(soops, &te->subtree, startx + UI_UNIT_X, starty); } - + /* vertical line */ te = lb->last; if (te->parent || lb->first != lb->last) { tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) { - + glRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2); } } @@ -1696,10 +1696,10 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + /* selection status */ if (TSELEM_OPEN(tselem, soops)) if (tselem->type == TSE_RNA_STRUCT) @@ -1718,10 +1718,10 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + /* selection status */ if (tselem->flag & TSE_SELECTED) { glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); @@ -1739,9 +1739,9 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio TreeElement *te; int starty, startx; float col[3]; - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once - + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* struct marks */ UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); @@ -1749,19 +1749,19 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); } - + /* always draw selection fill before hierarchy */ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); glColor3fv(col); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); - + // gray hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; startx = UI_UNIT_X / 2 - 1.0f; outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); - + // items themselves starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; startx = 0; @@ -1774,11 +1774,11 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio static void outliner_back(ARegion *ar) { int ystart; - + UI_ThemeColorShade(TH_BACK, 6); ystart = (int)ar->v2d.tot.ymax; ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { glRecti(0, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); ystart -= 2 * UI_UNIT_Y; @@ -1788,21 +1788,21 @@ static void outliner_back(ARegion *ar) static void outliner_draw_restrictcols(ARegion *ar) { int ystart; - + /* background underneath */ UI_ThemeColor(TH_BACK); glRecti((int)(ar->v2d.cur.xmax - OL_TOGW), (int)(ar->v2d.cur.ymin - 1), (int)ar->v2d.cur.xmax, (int)ar->v2d.cur.ymax); - + UI_ThemeColorShade(TH_BACK, 6); ystart = (int)ar->v2d.tot.ymax; ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { glRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); ystart -= 2 * UI_UNIT_Y; } - + UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* view */ @@ -1829,7 +1829,7 @@ static void outliner_draw_restrictcols(ARegion *ar) void draw_outliner(const bContext *C) { - Main *mainvar = CTX_data_main(C); + Main *mainvar = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; @@ -1839,7 +1839,7 @@ void draw_outliner(const bContext *C) TreeElement *te_edit = NULL; outliner_build_tree(mainvar, scene, soops); // always - + /* get extents of data */ outliner_height(soops, &soops->tree, &sizey); @@ -1851,11 +1851,11 @@ void draw_outliner(const bContext *C) * * (*) XXX max width for now is a fixed factor of (UI_UNIT_X * (max_indention + 100)) */ - + /* get actual width of column 1 */ outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); - + /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } @@ -1864,14 +1864,14 @@ void draw_outliner(const bContext *C) //outliner_width(soops, &soops->tree, &sizex); // XXX should use outliner_width instead when te->xend will be set correctly... outliner_rna_width(soops, &soops->tree, &sizex, 0); - + /* constant offset for restriction columns */ // XXX this isn't that great yet... if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) sizex += OL_TOGW * 3; - + } - + /* adds vertical offset */ sizey += OL_Y_OFFSET; @@ -1887,7 +1887,7 @@ void draw_outliner(const bContext *C) outliner_back(ar); block = UI_block_begin(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops, &te_edit); - + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* draw rna buttons */ outliner_draw_rnacols(ar, sizex_rna); @@ -1914,4 +1914,4 @@ void draw_outliner(const bContext *C) /* clear flag that allows quick redraws */ soops->storeflag &= ~SO_TREESTORE_REDRAW; -} +} diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index aed4b874886..7d5ff560b28 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -96,19 +96,19 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { /* check if this tree-element was the one we're seeking */ if (te == teFind) { *found = 1; return; } - + /* try to see if sub-tree contains it then */ outliner_open_reveal(soops, &te->subtree, teFind, found); if (*found) { tselem = TREESTORE(te); - if (tselem->flag & TSE_CLOSED) + if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; return; } @@ -154,10 +154,10 @@ TreeElement *outliner_dropzone_find(const SpaceOops *soops, const float fmval[2] static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, const bool all, const float mval[2]) { - + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); - + /* all below close/open? */ if (all) { tselem->flag &= ~TSE_CLOSED; @@ -167,16 +167,16 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } - + return 1; } - + for (te = te->subtree.first; te; te = te->next) { - if (do_outliner_item_openclose(C, soops, te, all, mval)) + if (do_outliner_item_openclose(C, soops, te, all, mval)) return 1; } return 0; - + } /* event can enterkey, then it opens/closes */ @@ -187,16 +187,16 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e TreeElement *te; float fmval[2]; const bool all = RNA_boolean_get(op->ptr, "all"); - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - + for (te = soops->tree.first; te; te = te->next) { - if (do_outliner_item_openclose(C, soops, te, all, fmval)) + if (do_outliner_item_openclose(C, soops, te, all, fmval)) break; } ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -205,11 +205,11 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) ot->name = "Open/Close Item"; ot->idname = "OUTLINER_OT_item_openclose"; ot->description = "Toggle whether item under cursor is enabled or closed"; - + ot->invoke = outliner_item_openclose; - + ot->poll = ED_operator_outliner_active; - + RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items"); } @@ -253,7 +253,7 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement { if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); - + /* click on name */ if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) { do_item_rename(ar, te, tselem, reports); @@ -261,7 +261,7 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement } return 0; } - + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_rename(reports, ar, te, mval)) return 1; } @@ -275,16 +275,16 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even TreeElement *te; float fmval[2]; bool changed = false; - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_rename(op->reports, ar, te, fmval)) { changed = true; break; } } - + return changed ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH; } @@ -294,9 +294,9 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) ot->name = "Rename Item"; ot->idname = "OUTLINER_OT_item_rename"; ot->description = "Rename item under cursor"; - + ot->invoke = outliner_item_rename; - + ot->poll = ED_operator_outliner_active; } @@ -718,9 +718,9 @@ static int outliner_count_levels(ListBase *lb, const int curlevel) { TreeElement *te; int level = curlevel, lev; - + for (te = lb->first; te; te = te->next) { - + lev = outliner_count_levels(&te->subtree, curlevel + 1); if (lev > level) level = lev; } @@ -732,11 +732,11 @@ int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel) TreeElement *te; TreeStoreElem *tselem; int level; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & flag) return curlevel; - + level = outliner_has_one_flag(&te->subtree, flag, curlevel + 1); if (level) return level; } @@ -747,7 +747,7 @@ void outliner_set_flag(ListBase *lb, short flag, short set) { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (set == 0) tselem->flag &= ~flag; @@ -776,7 +776,7 @@ int common_restrict_check(bContext *C, Object *ob) ob->restrictflag &= ~OB_RESTRICT_SELECT; return 0; } - + return 1; } @@ -799,7 +799,7 @@ void object_toggle_visibility_cb( /* add check for edit mode */ if (!common_restrict_check(C, ob)) return; - + if (base || (base = BKE_scene_base_find(scene, ob))) { if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); @@ -821,13 +821,13 @@ static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); - + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_visibility_cb); - + DAG_id_type_tag(bmain, ID_OB); WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -837,11 +837,11 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) ot->name = "Toggle Visibility"; ot->idname = "OUTLINER_OT_visibility_toggle"; ot->description = "Toggle the visibility of selected items"; - + /* callbacks */ ot->exec = outliner_toggle_visibility_exec; ot->poll = ED_operator_outliner_active_no_editobject; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -877,12 +877,12 @@ static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); - + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_selectability_cb); - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -892,11 +892,11 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) ot->name = "Toggle Selectability"; ot->idname = "OUTLINER_OT_selectability_toggle"; ot->description = "Toggle the selectability"; - + /* callbacks */ ot->exec = outliner_toggle_selectability_exec; ot->poll = ED_operator_outliner_active_no_editobject; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -932,12 +932,12 @@ static int outliner_toggle_renderability_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); - + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_renderability_cb); - + DAG_id_type_tag(bmain, ID_OB); WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); - + return OPERATOR_FINISHED; } @@ -947,11 +947,11 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) ot->name = "Toggle Renderability"; ot->idname = "OUTLINER_OT_renderability_toggle"; ot->description = "Toggle the renderability of selected items"; - + /* callbacks */ ot->exec = outliner_toggle_renderability_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -964,14 +964,14 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); - + if (outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1)) outliner_set_flag(&soops->tree, TSE_CLOSED, 0); - else + else outliner_set_flag(&soops->tree, TSE_CLOSED, 1); - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -981,11 +981,11 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) ot->name = "Expand/Collapse All"; ot->idname = "OUTLINER_OT_expanded_toggle"; ot->description = "Expand/Collapse all items"; - + /* callbacks */ ot->exec = outliner_toggle_expanded_exec; ot->poll = ED_operator_outliner_active; - + /* no undo or registry, UI option */ } @@ -996,17 +996,17 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - + if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1)) outliner_set_flag(&soops->tree, TSE_SELECTED, 0); - else + else outliner_set_flag(&soops->tree, TSE_SELECTED, 1); - + soops->storeflag |= SO_TREESTORE_REDRAW; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1016,11 +1016,11 @@ void OUTLINER_OT_selected_toggle(wmOperatorType *ot) ot->name = "Toggle Selected"; ot->idname = "OUTLINER_OT_selected_toggle"; ot->description = "Toggle the Outliner selection of items"; - + /* callbacks */ ot->exec = outliner_toggle_selected_exec; ot->poll = ED_operator_outliner_active; - + /* no undo or registry, UI option */ } @@ -1079,7 +1079,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; - + TreeElement *te; int xdelta, ytop; @@ -1118,20 +1118,20 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) /* make te->ys center of view */ ytop = te->ys + BLI_rcti_size_y(&v2d->mask) / 2; if (ytop > 0) ytop = 0; - + v2d->cur.ymax = (float)ytop; v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); - + /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); v2d->cur.xmin += xdelta; v2d->cur.xmax += xdelta; - + so->storeflag |= SO_TREESTORE_REDRAW; } - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1141,7 +1141,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) ot->name = "Show Active"; ot->idname = "OUTLINER_OT_show_active"; ot->description = "Open up the tree and adjust the view so that the active Object is shown centered"; - + /* callbacks */ ot->exec = outliner_show_active_exec; ot->poll = ED_operator_outliner_active; @@ -1154,16 +1154,16 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); int dy = BLI_rcti_size_y(&ar->v2d.mask); int up = 0; - + if (RNA_boolean_get(op->ptr, "up")) up = 1; if (up == 0) dy = -dy; ar->v2d.cur.ymin += dy; ar->v2d.cur.ymax += dy; - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1176,11 +1176,11 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot) ot->name = "Scroll Page"; ot->idname = "OUTLINER_OT_scroll_page"; ot->description = "Scroll page up or down"; - + /* callbacks */ ot->exec = outliner_scroll_page_exec; ot->poll = ED_operator_outliner_active; - + /* properties */ prop = RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -1196,14 +1196,14 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam TreeElement *prev, int *prevFound) { TreeElement *te, *tes; - + for (te = lb->first; te; te = te->next) { int found = outliner_filter_has_name(te, name, flags); - + if (found) { /* name is right, but is element the previous one? */ if (prev) { - if ((te != prev) && (*prevFound)) + if ((te != prev) && (*prevFound)) return te; if (te == prev) { *prevFound = 1; @@ -1212,7 +1212,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam else return te; } - + tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); if (tes) return tes; } @@ -1221,7 +1221,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam return NULL; } -static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) +static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) { ReportList *reports = NULL; // CTX_wm_reports(C); TreeElement *te = NULL; @@ -1229,16 +1229,16 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so TreeStoreElem *tselem; int ytop, xdelta, prevFound = 0; char name[sizeof(soops->search_string)]; - + /* get last found tree-element based on stored search_tse */ last_find = outliner_find_tse(soops, &soops->search_tse); - + /* determine which type of search to do */ if (again && last_find) { /* no popup panel - previous + user wanted to search for next after previous */ BLI_strncpy(name, soops->search_string, sizeof(name)); flags = soops->search_flags; - + /* try to find matching element */ te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); if (te == NULL) { @@ -1263,28 +1263,28 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* expand branches so that it will be visible, we need to get correct coordinates */ if (outliner_open_back(soops, te)) outliner_set_coordinates(ar, soops); - + /* deselect all visible, and select found element */ outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; - + /* make te->ys center of view */ ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2); if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask)); - + /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); ar->v2d.cur.xmin += xdelta; ar->v2d.cur.xmax += xdelta; - + /* store selection */ soops->search_tse = *tselem; - + BLI_strncpy(soops->search_string, name, sizeof(soops->search_string)); soops->search_flags = flags; - + /* redraw */ soops->storeflag |= SO_TREESTORE_REDRAW; } @@ -1303,17 +1303,17 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + if (open) { if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; } else { if (curlevel >= level) tselem->flag |= TSE_CLOSED; } - + outliner_openclose_level(&te->subtree, curlevel + 1, level, open); } } @@ -1324,7 +1324,7 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); const bool add = RNA_boolean_get(op->ptr, "open"); int level; - + level = outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1); if (add == 1) { if (level) outliner_openclose_level(&soops->tree, 1, level, 1); @@ -1333,9 +1333,9 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) if (level == 0) level = outliner_count_levels(&soops->tree, 0); if (level) outliner_openclose_level(&soops->tree, 1, level - 1, 0); } - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1347,13 +1347,13 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot) ot->name = "Show/Hide One Level"; ot->idname = "OUTLINER_OT_show_one_level"; ot->description = "Expand/collapse all entries by one level"; - + /* callbacks */ ot->exec = outliner_one_level_exec; ot->poll = ED_operator_outliner_active; - + /* no undo or registry, UI option */ - + /* properties */ prop = RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -1366,7 +1366,7 @@ static int subtree_has_objects(ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) return 1; @@ -1384,7 +1384,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase /* open all object elems, close others */ for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + if (tselem->type == 0) { if (te->idcode == ID_SCE) { if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; @@ -1411,12 +1411,12 @@ static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - + /* recursively open/close levels */ tree_element_show_hierarchy(scene, soops, &soops->tree); - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1426,11 +1426,11 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) ot->name = "Show Hierarchy"; ot->idname = "OUTLINER_OT_show_hierarchy"; ot->description = "Open all object entries and close all others"; - + /* callbacks */ ot->exec = outliner_show_hierarchy_exec; ot->poll = ED_operator_outliner_active; // TODO: shouldn't be allowed in RNA views... - + /* no undo or registry, UI option */ } @@ -1450,7 +1450,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C) } -/* Helper func to extract an RNA path from selected tree element +/* Helper func to extract an RNA path from selected tree element * NOTE: the caller must zero-out all values of the pointers that it passes here first, as * this function does not do that yet */ @@ -1464,29 +1464,29 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, PointerRNA *ptr, *nextptr; PropertyRNA *prop; char *newpath = NULL; - + /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed */ if (tselem->type == TSE_RNA_STRUCT) return; - + /* Overview of Algorithm: * 1. Go up the chain of parents until we find the 'root', taking note of the * levels encountered in reverse-order (i.e. items are added to the start of the list * for more convenient looping later) * 2. Walk down the chain, adding from the first ID encountered - * (which will become the 'ID' for the KeyingSet Path), and build a + * (which will become the 'ID' for the KeyingSet Path), and build a * path as we step through the chain */ - + /* step 1: flatten out hierarchy of parents into a flat chain */ for (tem = te->parent; tem; tem = tem->parent) { ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); ld->data = tem; BLI_addhead(&hierarchy, ld); } - + /* step 2: step down hierarchy building the path * (NOTE: addhead in previous loop was needed so that we can loop like this) */ for (ld = hierarchy.first; ld; ld = ld->next) { @@ -1495,10 +1495,10 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, tse = TREESTORE(tem); ptr = &tem->rnaptr; prop = tem->directdata; - + /* check if we're looking for first ID, or appending to path */ if (*id) { - /* just 'append' property to path + /* just 'append' property to path * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them */ if (tse->type == TSE_RNA_PROPERTY) { @@ -1508,35 +1508,35 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, } else if (RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - + temnext = (TreeElement *)(ld->next->data); /* tsenext = TREESTORE(temnext); */ /* UNUSED */ - + nextptr = &temnext->rnaptr; name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); - + if (name) { /* if possible, use name as a key in the path */ newpath = RNA_path_append(*path, NULL, prop, 0, name); - + if (name != buf) MEM_freeN(name); } else { /* otherwise use index */ int index = 0; - + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) if (temsub == temnext) break; - + newpath = RNA_path_append(*path, NULL, prop, index, NULL); } - + ld = ld->next; } } - + if (newpath) { if (*path) MEM_freeN(*path); *path = newpath; @@ -1550,7 +1550,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, * since ptr->data is sometimes the owner of this ID? */ if (RNA_struct_is_ID(ptr->type)) { *id = (ID *)ptr->data; - + /* clear path */ if (*path) { MEM_freeN(*path); @@ -1566,7 +1566,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* add the active property to the path */ ptr = &te->rnaptr; prop = te->directdata; - + /* array checks */ if (tselem->type == TSE_RNA_ARRAY_ELEM) { /* item is part of an array, so must set the array_index */ @@ -1576,7 +1576,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* entire array was selected, so keyframe all */ *flag |= KSP_FLAG_WHOLE_ARRAY; } - + /* path */ newpath = RNA_path_append(*path, NULL, prop, 0, NULL); if (*path) MEM_freeN(*path); @@ -1598,17 +1598,17 @@ enum { DRIVERS_EDITMODE_REMOVE, } /*eDrivers_EditModes*/; -/* Utilities ---------------------------------- */ +/* Utilities ---------------------------------- */ /* Recursively iterate over tree, finding and working on selected items */ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode) { TreeElement *te; TreeStoreElem *tselem; - + for (te = tree->first; te; te = te->next) { tselem = TREESTORE(te); - + /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { ID *id = NULL; @@ -1616,7 +1616,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL int array_index = 0; short flag = 0; short groupmode = KSP_GROUP_KSNAME; - + /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) @@ -1625,12 +1625,12 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); } - + /* only if ID and path were set, should we perform any actions */ if (id && path) { short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR; int arraylen = 1; - + /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { /* entire array was selected, so add drivers for all */ @@ -1638,11 +1638,11 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL } else arraylen = array_index; - + /* we should do at least one step */ if (arraylen == array_index) arraylen++; - + /* for each array element we should affect, add driver */ for (; array_index < arraylen; array_index++) { /* action depends on mode */ @@ -1661,14 +1661,14 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL } } } - + /* free path, since it had to be generated */ MEM_freeN(path); } - - + + } - + /* go over sub-tree */ if (TSELEM_OPEN(tselem, soops)) do_outliner_drivers_editop(soops, &te->subtree, reports, mode); @@ -1680,17 +1680,17 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) { SpaceOops *soutliner = CTX_wm_space_outliner(C); - + /* check for invalid states */ if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); - + /* send notifiers */ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX - + return OPERATOR_FINISHED; } @@ -1700,11 +1700,11 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_drivers_add_selected"; ot->name = "Add Drivers for Selected"; ot->description = "Add drivers to selected items"; - + /* api callbacks */ ot->exec = outliner_drivers_addsel_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1715,17 +1715,17 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) { SpaceOops *soutliner = CTX_wm_space_outliner(C); - + /* check for invalid states */ if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE); - + /* send notifiers */ WM_event_add_notifier(C, ND_KEYS, NULL); // XXX - + return OPERATOR_FINISHED; } @@ -1735,11 +1735,11 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_drivers_delete_selected"; ot->name = "Delete Drivers for Selected"; ot->description = "Delete drivers assigned to selected items"; - + /* api callbacks */ ot->exec = outliner_drivers_deletesel_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1755,29 +1755,29 @@ enum { KEYINGSET_EDITMODE_REMOVE, } /*eKeyingSet_EditModes*/; -/* Utilities ---------------------------------- */ - +/* Utilities ---------------------------------- */ + /* find the 'active' KeyingSet, and add if not found (if adding is allowed) */ // TODO: should this be an API func? static KeyingSet *verify_active_keyingset(Scene *scene, short add) { KeyingSet *ks = NULL; - + /* sanity check */ if (scene == NULL) return NULL; - + /* try to find one from scene */ if (scene->active_keyingset > 0) ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); - + /* add if none found */ // XXX the default settings have yet to evolve if ((add) && (ks == NULL)) { ks = BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset = BLI_listbase_count(&scene->keyingsets); } - + return ks; } @@ -1786,10 +1786,10 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa { TreeElement *te; TreeStoreElem *tselem; - + for (te = tree->first; te; te = te->next) { tselem = TREESTORE(te); - + /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { ID *id = NULL; @@ -1797,7 +1797,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa int array_index = 0; short flag = 0; short groupmode = KSP_GROUP_KSNAME; - + /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) @@ -1806,7 +1806,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); } - + /* only if ID and path were set, should we perform any actions */ if (id && path) { /* action depends on mode */ @@ -1824,7 +1824,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa { /* find the relevant path, then remove it from the KeyingSet */ KS_Path *ksp = BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); - + if (ksp) { /* free path's data */ BKE_keyingset_free_path(ks, ksp); @@ -1834,12 +1834,12 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa break; } } - + /* free path, since it had to be generated */ MEM_freeN(path); } } - + /* go over sub-tree */ if (TSELEM_OPEN(tselem, soops)) do_outliner_keyingset_editop(soops, ks, &te->subtree, mode); @@ -1853,7 +1853,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) SpaceOops *soutliner = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = verify_active_keyingset(scene, 1); - + /* check for invalid states */ if (ks == NULL) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set"); @@ -1861,13 +1861,13 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) } if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } @@ -1877,11 +1877,11 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_keyingset_add_selected"; ot->name = "Keying Set Add Selected"; ot->description = "Add selected items (blue-gray rows) to active Keying Set"; - + /* api callbacks */ ot->exec = outliner_keyingset_additems_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1894,17 +1894,17 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o SpaceOops *soutliner = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = verify_active_keyingset(scene, 1); - + /* check for invalid states */ if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } @@ -1914,11 +1914,11 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_keyingset_remove_selected"; ot->name = "Keying Set Remove Selected"; ot->description = "Remove selected items (blue-gray rows) from active Keying Set"; - + /* api callbacks */ ot->exec = outliner_keyingset_removeitems_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1954,7 +1954,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *UNUSED(op)) * are retained... */ WM_operator_name_call(C, "WM_OT_save_mainfile", WM_OP_EXEC_DEFAULT, NULL); - + /* Now, reload the file to get rid of the orphans... */ WM_operator_name_call(C, "WM_OT_revert_mainfile", WM_OP_EXEC_DEFAULT, NULL); return OPERATOR_FINISHED; @@ -1967,12 +1967,12 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) ot->name = "Purge All"; ot->description = "Clear all orphaned data-blocks without any users from the file " "(cannot be undone, saves to current .blend file)"; - + /* callbacks */ ot->invoke = outliner_orphans_purge_invoke; ot->exec = outliner_orphans_purge_exec; ot->poll = ed_operator_outliner_id_orphans_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2036,7 +2036,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname); - + if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); return OPERATOR_CANCELLED; @@ -2048,7 +2048,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) BKE_report(op->reports, RPT_INFO, "Can't edit library linked object"); return OPERATOR_CANCELLED; } - + scene = (Scene *)outliner_search_back(soops, te, ID_SCE); if (scene == NULL) { @@ -2073,7 +2073,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); PointerRNA ptr; - + /* Cannot use uiItemEnumO()... have multiple properties to set. */ uiItemFullO_ptr(layout, ot, IFACE_("Object"), 0, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr); RNA_string_set(&ptr, "parent", parname); @@ -2129,9 +2129,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) RNA_string_set(&ptr, "child", childname); RNA_enum_set(&ptr, "type", PAR_LATTICE); } - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } } diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 674a2bceccc..9bf2231b313 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -85,7 +85,7 @@ typedef enum { OL_SETSEL_EXTEND = 2, /* select the item and extend (also toggles selection) */ } eOLSetState; -/* get TreeStoreElem associated with a TreeElement +/* get TreeStoreElem associated with a TreeElement * < a: (TreeElement) tree element to find stored element for */ #define TREESTORE(a) ((a)->store_elem) diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 36b5da72e91..ad2b8008db6 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -66,20 +66,20 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_show_active); WM_operatortype_append(OUTLINER_OT_show_hierarchy); WM_operatortype_append(OUTLINER_OT_scroll_page); - + WM_operatortype_append(OUTLINER_OT_selected_toggle); WM_operatortype_append(OUTLINER_OT_expanded_toggle); - + WM_operatortype_append(OUTLINER_OT_renderability_toggle); WM_operatortype_append(OUTLINER_OT_selectability_toggle); WM_operatortype_append(OUTLINER_OT_visibility_toggle); - + WM_operatortype_append(OUTLINER_OT_keyingset_add_selected); WM_operatortype_append(OUTLINER_OT_keyingset_remove_selected); - + WM_operatortype_append(OUTLINER_OT_drivers_add_selected); WM_operatortype_append(OUTLINER_OT_drivers_delete_selected); - + WM_operatortype_append(OUTLINER_OT_orphans_purge); WM_operatortype_append(OUTLINER_OT_parent_drop); @@ -93,7 +93,7 @@ void outliner_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Outliner", SPACE_OUTLINER, 0); wmKeyMapItem *kmi; - + WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0); kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, 0, 0); @@ -114,44 +114,44 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OUTLINER_OT_select_border", BKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "all", false); kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "all", true); - + WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_operation", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_show_hierarchy", HOMEKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PERIODKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PADPERIOD, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEDOWNKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "up", false); kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEUPKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "up", true); - + WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADPLUSKEY, KM_PRESS, 0, 0); /* open */ kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "open", false); /* close */ - + WM_keymap_verify_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_verify_item(keymap, "OUTLINER_OT_renderability_toggle", RKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_selectability_toggle", SKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_visibility_toggle", VKEY, KM_PRESS, 0, 0); - - + + /* keying sets - only for databrowse */ WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 199043fc39a..5149715740f 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -76,26 +76,26 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se TreeElement *te; TreeStoreElem *tselem; bool changed = false; - + for (te = lb->first; te && *index >= 0; te = te->next, (*index)--) { tselem = TREESTORE(te); - + /* if we've encountered the right item, set its 'Outliner' selection status */ if (*index == 0) { /* this should be the last one, so no need to do anything with index */ if ((te->flag & TE_ICONROW) == 0) { /* -1 value means toggle testing for now... */ if (*selecting == -1) { - if (tselem->flag & TSE_SELECTED) + if (tselem->flag & TSE_SELECTED) *selecting = 0; - else + else *selecting = 1; } - + /* set selection */ - if (*selecting) + if (*selecting) tselem->flag |= TSE_SELECTED; - else + else tselem->flag &= ~TSE_SELECTED; changed |= true; @@ -125,12 +125,12 @@ static eOLDrawState tree_element_active_renderlayer( bContext *C, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { Scene *sce; - + /* paranoia check */ if (te->idcode != ID_SCE) return OL_DRAWSEL_NONE; sce = (Scene *)tselem->id; - + if (set != OL_SETSEL_NONE) { sce->r.actlay = tselem->nr; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); @@ -191,7 +191,7 @@ static eOLDrawState tree_element_set_active_object( Scene *sce; Base *base; Object *ob = NULL; - + /* if id is not object, we search back */ if (te->idcode == ID_OB) { ob = (Object *)tselem->id; @@ -205,13 +205,13 @@ static eOLDrawState tree_element_set_active_object( if (ob == NULL) { return OL_DRAWSEL_NONE; } - + sce = (Scene *)outliner_search_back(soops, te, ID_SCE); if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); scene = sce; } - + /* find associated base in current scene */ base = BKE_scene_base_find(scene, ob); @@ -220,7 +220,7 @@ static eOLDrawState tree_element_set_active_object( /* swap select */ if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); - else + else ED_base_object_select(base, BA_SELECT); } else { @@ -239,10 +239,10 @@ static eOLDrawState tree_element_set_active_object( WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } - + if (ob != scene->obedit) ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); - + return OL_DRAWSEL_NORMAL; } @@ -252,14 +252,14 @@ static eOLDrawState tree_element_active_material( { TreeElement *tes; Object *ob; - + /* 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 OL_DRAWSEL_NONE; /* just paranoia */ } - + /* searching in ob mat array? */ tes = te->parent; if (tes->idcode == ID_OB) { @@ -307,21 +307,21 @@ static eOLDrawState tree_element_active_texture( TreeStoreElem /* *tselem,*/ *tselemp; Object *ob = OBACT; SpaceButs *sbuts = NULL; - + if (ob == NULL) { /* no active object */ return OL_DRAWSEL_NONE; } - + /*tselem = TREESTORE(te);*/ /*UNUSED*/ - + /* find buttons region (note, this is undefined really still, needs recode in blender) */ /* XXX removed finding sbuts */ - + /* where is texture linked to? */ tep = te->parent; tselemp = TREESTORE(tep); - + if (tep->idcode == ID_WO) { World *wrld = (World *)tselemp->id; @@ -366,7 +366,7 @@ static eOLDrawState tree_element_active_texture( } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture ma->texact = (char)te->index; - + /* also set active material */ ob->actcol = tep->index + 1; } @@ -376,7 +376,7 @@ static eOLDrawState tree_element_active_texture( } } } - + if (set != OL_SETSEL_NONE) { WM_event_add_notifier(C, NC_TEXTURE, NULL); } @@ -391,21 +391,21 @@ static eOLDrawState tree_element_active_lamp( TreeElement *te, const eOLSetState set) { Object *ob; - + /* we search for the object parent */ ob = (Object *)outliner_search_back(soops, te, ID_OB); if (ob == NULL || ob != OBACT) { /* just paranoia */ return OL_DRAWSEL_NONE; } - + if (set != OL_SETSEL_NONE) { // XXX extern_set_butspace(F5KEY, 0); } else { return OL_DRAWSEL_NORMAL; } - + return OL_DRAWSEL_NONE; } @@ -429,21 +429,21 @@ static eOLDrawState tree_element_active_world( TreeElement *tep; TreeStoreElem *tselem = NULL; Scene *sce = NULL; - + tep = te->parent; if (tep) { tselem = TREESTORE(tep); if (tselem->type == 0) sce = (Scene *)tselem->id; } - + if (set != OL_SETSEL_NONE) { /* 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 != OL_SETSEL_NONE) { // XXX extern_set_butspace(F8KEY, 0); @@ -459,7 +459,7 @@ static eOLDrawState tree_element_active_defgroup( bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { Object *ob; - + /* id in tselem is object */ ob = (Object *)tselem->id; if (set != OL_SETSEL_NONE) { @@ -483,7 +483,7 @@ static eOLDrawState tree_element_active_posegroup( bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { Object *ob = (Object *)tselem->id; - + if (set != OL_SETSEL_NONE) { if (ob->pose) { ob->pose->active_group = te->index + 1; @@ -506,10 +506,10 @@ static eOLDrawState tree_element_active_posechannel( Object *ob = (Object *)tselem->id; bArmature *arm = ob->data; bPoseChannel *pchan = te->directdata; - + if (set != OL_SETSEL_NONE) { if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - + if (set != OL_SETSEL_EXTEND) { bPoseChannel *pchannel; /* single select forces all other bones to get unselected */ @@ -549,7 +549,7 @@ static eOLDrawState tree_element_active_bone( { bArmature *arm = (bArmature *)tselem->id; Bone *bone = te->directdata; - + if (set != OL_SETSEL_NONE) { if (!(bone->flag & BONE_HIDDEN_P)) { Object *ob = OBACT; @@ -562,7 +562,7 @@ static eOLDrawState tree_element_active_bone( } } } - + if (set == OL_SETSEL_EXTEND && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; } @@ -576,13 +576,13 @@ static eOLDrawState tree_element_active_bone( do_outliner_bone_select_recursive(arm, bone, (bone->flag & BONE_SELECTED) != 0); } - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob); } } else { Object *ob = OBACT; - + if (ob && ob->data == arm) { if (bone->flag & BONE_SELECTED) { return OL_DRAWSEL_NORMAL; @@ -658,12 +658,12 @@ static eOLDrawState tree_element_active_modifier( { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; - + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); // XXX extern_set_butspace(F9KEY, 0); } - + return OL_DRAWSEL_NONE; } @@ -672,12 +672,12 @@ static eOLDrawState tree_element_active_psys( { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; - + WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); - + // XXX extern_set_butspace(F7KEY, 0); } - + return OL_DRAWSEL_NONE; } @@ -686,11 +686,11 @@ static int tree_element_active_constraint( { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); // XXX extern_set_butspace(F7KEY, 0); } - + return OL_DRAWSEL_NONE; } @@ -717,7 +717,7 @@ static eOLDrawState tree_element_active_pose( if (scene->obedit) { ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); } - + if (ob->mode & OB_MODE_POSE) { ED_object_posemode_exit(C, ob); } @@ -798,7 +798,7 @@ static eOLDrawState tree_element_active_keymap_item( bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set) { wmKeyMapItem *kmi = te->directdata; - + if (set == OL_SETSEL_NONE) { if (kmi->flag & KMI_INACTIVE) { return OL_DRAWSEL_NONE; @@ -888,7 +888,7 @@ eOLDrawState tree_element_type_active( case TSE_GP_LAYER: //return tree_element_active_gplayer(C, scene, te, tselem, set); break; - + } return OL_DRAWSEL_NONE; } @@ -977,13 +977,13 @@ static bool do_outliner_item_activate_from_cursor( if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); bool openclose = false; - + /* 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) openclose = true; } - + if (openclose) { /* all below close/open? */ if (extend) { @@ -993,9 +993,9 @@ static bool do_outliner_item_activate_from_cursor( else { if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; - + } - + return true; } /* name and first icon */ @@ -1007,7 +1007,7 @@ static bool do_outliner_item_activate_from_cursor( return true; } } - + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_activate_from_cursor(C, scene, ar, soops, te, extend, recursive, mval)) { return true; @@ -1064,29 +1064,29 @@ int outliner_item_do_activate_from_cursor( break; } } - + if (te) { ED_undo_push(C, "Outliner click event"); } else { short selecting = -1; int row; - + /* get row number - 100 here is just a dummy value since we don't need the column */ - UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, + UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, fmval[0], fmval[1], NULL, &row); - + /* select relevant row */ if (outliner_select(soops, &soops->tree, &row, &selecting)) { - + soops->storeflag |= SO_TREESTORE_REDRAW; - + /* no need for undo push here, only changing outliner data which is * scene level - campbell */ /* ED_undo_push(C, "Outliner selection event"); */ } } - + ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -1105,11 +1105,11 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->name = "Activate Item"; ot->idname = "OUTLINER_OT_item_activate"; ot->description = "Handle mouse clicks to activate/select items"; - + ot->invoke = outliner_item_activate; - + ot->poll = ED_operator_outliner_active; - + RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children"); } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 0fcebc53f58..75151325bdf 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -96,7 +96,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -115,7 +115,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, case ID_OB: *objectlevel = 1; break; - + case ID_ME: case ID_CU: case ID_MB: case ID_LT: case ID_LA: case ID_AR: case ID_CA: case ID_SPK: case ID_MA: case ID_TE: case ID_IP: case ID_IM: @@ -149,7 +149,7 @@ static void unlink_material_cb( { Material **matar = NULL; int a, totcol = 0; - + if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; totcol = ob->totcol; @@ -190,7 +190,7 @@ static void unlink_texture_cb( { MTex **mtex = NULL; int a; - + if (GS(tsep->id->name) == ID_MA) { Material *ma = (Material *)tsep->id; mtex = ma->mtex; @@ -226,7 +226,7 @@ static void unlink_group_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) { Group *group = (Group *)tselem->id; - + if (tsep) { if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; @@ -245,7 +245,7 @@ static void unlink_world_cb( { Scene *parscene = (Scene *)tsep->id; World *wo = (World *)tselem->id; - + /* need to use parent scene not just scene, otherwise may end up getting wrong one */ id_us_min(&wo->id); parscene->world = NULL; @@ -258,7 +258,7 @@ static void outliner_do_libdata_operation( { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -363,7 +363,7 @@ static void object_select_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { Base *base = (Base *)te->directdata; - + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0)) { base->flag |= SELECT; @@ -385,7 +385,7 @@ static void object_deselect_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { Base *base = (Base *)te->directdata; - + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->flag &= ~SELECT; @@ -398,7 +398,7 @@ static void object_delete_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *user_data) { Base *base = (Base *)te->directdata; - + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { @@ -420,7 +420,7 @@ static void object_delete_cb( if (scene->obedit == base->object) { ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); } - + ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); /* leave for ED_outliner_id_unref to handle */ #if 0 @@ -459,7 +459,7 @@ static void id_fake_user_set_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + id_fake_user_set(id); } @@ -468,7 +468,7 @@ static void id_fake_user_clear_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + id_fake_user_clear(id); } @@ -486,15 +486,15 @@ static void singleuser_action_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + if (id) { IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id; PointerRNA ptr = {{NULL}}; PropertyRNA *prop; - + RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr); prop = RNA_struct_find_property(&ptr, "action"); - + id_single_user(C, id, &ptr, prop); } } @@ -504,16 +504,16 @@ static void singleuser_world_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + /* need to use parent scene not just scene, otherwise may end up getting wrong one */ if (id) { Scene *parscene = (Scene *)tsep->id; PointerRNA ptr = {{NULL}}; PropertyRNA *prop; - + RNA_id_pointer_create(&parscene->id, &ptr); prop = RNA_struct_find_property(&ptr, "world"); - + id_single_user(C, id, &ptr, prop); } } @@ -558,7 +558,7 @@ void outliner_do_object_operation_ex( outliner_operation_cb operation_cb, bool select_recurse) { TreeElement *te; - + for (te = lb->first; te; te = te->next) { TreeStoreElem *tselem = TREESTORE(te); bool select_handled = false; @@ -612,7 +612,7 @@ static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem, void *UNUSED(arg)) { IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id; - + /* just free drivers - stored as a list of F-Curves */ free_fcurves(&iat->adt->drivers); } @@ -622,11 +622,11 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te { IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id; FCurve *fcu; - + /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */ for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; - + if (fcu->driver) fcu->driver->flag &= ~DRIVER_FLAG_INVALID; } @@ -657,7 +657,7 @@ typedef enum eOutliner_PropModifierOps { static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { bPoseChannel *pchan = (bPoseChannel *)te->directdata; - + if (event == OL_DOP_SELECT) pchan->bone->flag |= BONE_SELECTED; else if (event == OL_DOP_DESELECT) @@ -673,7 +673,7 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { Bone *bone = (Bone *)te->directdata; - + if (event == OL_DOP_SELECT) bone->flag |= BONE_SELECTED; else if (event == OL_DOP_DESELECT) @@ -689,7 +689,7 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), v static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { EditBone *ebone = (EditBone *)te->directdata; - + if (event == OL_DOP_SELECT) ebone->flag |= BONE_SELECTED; else if (event == OL_DOP_DESELECT) @@ -719,7 +719,7 @@ static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void static void gp_layer_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { bGPDlayer *gpl = (bGPDlayer *)te->directdata; - + if (event == OL_DOP_SELECT) gpl->flag |= GP_LAYER_SELECT; else if (event == OL_DOP_DESELECT) @@ -811,7 +811,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -927,11 +927,11 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); int event; const char *str = NULL; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); if (event == OL_OP_SELECT) { @@ -940,7 +940,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } - + str = "Select Objects"; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -949,7 +949,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) outliner_do_object_operation_ex(C, op->reports, scene, soops, &soops->tree, object_select_hierarchy_cb, false); if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); - } + } str = "Select Object Hierarchy"; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -1015,7 +1015,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } ED_undo_push(C, str); - + return OPERATOR_FINISHED; } @@ -1026,12 +1026,12 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot) ot->name = "Outliner Object Operation"; ot->idname = "OUTLINER_OT_object_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_object_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; ot->prop = RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", ""); @@ -1072,11 +1072,11 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); SpaceOops *soops = CTX_wm_space_outliner(C); int event; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); switch (event) { @@ -1129,14 +1129,14 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot) ot->name = "Outliner Group Operation"; ot->idname = "OUTLINER_OT_group_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_group_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", ""); } @@ -1144,13 +1144,13 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot) typedef enum eOutlinerIdOpTypes { OUTLINER_IDOP_INVALID = 0, - + OUTLINER_IDOP_UNLINK, OUTLINER_IDOP_LOCAL, OUTLINER_IDOP_SINGLE, OUTLINER_IDOP_DELETE, OUTLINER_IDOP_REMAP, - + OUTLINER_IDOP_FAKE_ADD, OUTLINER_IDOP_FAKE_CLEAR, OUTLINER_IDOP_RENAME, @@ -1180,15 +1180,15 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutlinerIdOpTypes event; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + event = RNA_enum_get(op->ptr, "type"); - + switch (event) { case OUTLINER_IDOP_UNLINK: { @@ -1196,25 +1196,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) switch (idlevel) { case ID_AC: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_action_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case ID_MA: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_material_cb, NULL); - + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink material"); break; case ID_TE: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_texture_cb, NULL); - + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink texture"); break; case ID_WO: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_world_cb, NULL); - + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Unlink world"); break; @@ -1237,18 +1237,18 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) switch (idlevel) { case ID_AC: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_action_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Single-User Action"); break; - + case ID_WO: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_world_cb, NULL); - + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Single-User World"); break; - + default: BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; @@ -1275,7 +1275,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) { /* set fake user */ outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_set_cb, NULL); - + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Add Fake User"); break; @@ -1284,7 +1284,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) { /* clear fake user */ outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_clear_cb, NULL); - + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Clear Fake User"); break; @@ -1293,7 +1293,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) { /* rename */ outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL); - + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Rename"); break; @@ -1302,18 +1302,18 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_select_linked_cb, NULL); ED_undo_push(C, "Select"); break; - + default: // invalid - unhandled break; } - + /* wrong notifier still... */ WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); - - // XXX: this is just so that outliner is always up to date + + // XXX: this is just so that outliner is always up to date WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); - + return OPERATOR_FINISHED; } @@ -1324,14 +1324,14 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) ot->name = "Outliner ID data Operation"; ot->idname = "OUTLINER_OT_id_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_id_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); } @@ -1435,7 +1435,7 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -1455,12 +1455,12 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId) { bAction *act = (bAction *)actId; - + if (tselem->type == TSE_ANIM_DATA) { /* "animation" entries - action is child of this */ BKE_animdata_set_action(NULL, tselem->id, act); } - /* TODO: if any other "expander" channels which own actions need to support this menu, + /* TODO: if any other "expander" channels which own actions need to support this menu, * add: tselem->type = ... */ else if (tsep && (tsep->type == TSE_ANIM_DATA)) { @@ -1474,17 +1474,17 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) { SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; - + bAction *act; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + /* get action to use */ act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); - + if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid action to add"); return OPERATOR_CANCELLED; @@ -1497,7 +1497,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) "for this action to avoid future problems)", act->id.name + 2); } - + /* perform action if valid channel */ if (datalevel == TSE_ANIM_DATA) outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); @@ -1505,11 +1505,11 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); else return OPERATOR_CANCELLED; - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Set action"); - + /* done */ return OPERATOR_FINISHED; } @@ -1522,15 +1522,15 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) ot->name = "Outliner Set Action"; ot->idname = "OUTLINER_OT_action_set"; ot->description = "Change the active action used"; - + /* api callbacks */ ot->invoke = WM_enum_search_invoke; ot->exec = outliner_action_set_exec; ot->poll = ED_operator_outliner_active; - + /* flags */ ot->flag = 0; - + /* props */ // TODO: this would be nicer as an ID-pointer... prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); @@ -1543,15 +1543,15 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) typedef enum eOutliner_AnimDataOps { OUTLINER_ANIMOP_INVALID = 0, - + OUTLINER_ANIMOP_CLEAR_ADT, - + OUTLINER_ANIMOP_SET_ACT, OUTLINER_ANIMOP_CLEAR_ACT, - + OUTLINER_ANIMOP_REFRESH_DRV, OUTLINER_ANIMOP_CLEAR_DRV - + //OUTLINER_ANIMOP_COPY_DRIVERS, //OUTLINER_ANIMOP_PASTE_DRIVERS } eOutliner_AnimDataOps; @@ -1573,66 +1573,66 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_AnimDataOps event; short updateDeps = 0; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + if (datalevel != TSE_ANIM_DATA) return OPERATOR_CANCELLED; - + /* perform the core operation */ switch (event) { case OUTLINER_ANIMOP_CLEAR_ADT: /* Remove Animation Data - this may remove the active action, in some cases... */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, clear_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Clear Animation Data"); break; - + case OUTLINER_ANIMOP_SET_ACT: /* delegate once again... */ WM_operator_name_call(C, "OUTLINER_OT_action_set", WM_OP_INVOKE_REGION_WIN, NULL); break; - + case OUTLINER_ANIMOP_CLEAR_ACT: /* clear active action - using standard rules */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; - + case OUTLINER_ANIMOP_REFRESH_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ updateDeps = 1; break; - + case OUTLINER_ANIMOP_CLEAR_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); ED_undo_push(C, "Clear Drivers"); updateDeps = 1; break; - + default: // invalid break; } - + /* update dependencies */ if (updateDeps) { /* rebuild depsgraph for the new deps */ DAG_relations_tag_update(CTX_data_main(C)); } - + return OPERATOR_FINISHED; } @@ -1643,14 +1643,14 @@ void OUTLINER_OT_animdata_operation(wmOperatorType *ot) ot->name = "Outliner Animation Data Operation"; ot->idname = "OUTLINER_OT_animdata_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_animdata_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_animdata_op_types, 0, "Animation Operation", ""); } @@ -1763,14 +1763,14 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_PropDataOps event; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + switch (datalevel) { case TSE_POSE_CHANNEL: { @@ -1822,7 +1822,7 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } - + return OPERATOR_FINISHED; } @@ -1833,14 +1833,14 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) ot->name = "Outliner Data Operation"; ot->idname = "OUTLINER_OT_data_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_data_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); } @@ -1852,25 +1852,25 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop TreeElement *te, const float mval[2]) { ReportList *reports = CTX_wm_reports(C); // XXX... - + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; TreeStoreElem *tselem = TREESTORE(te); - + /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - + if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1)) outliner_set_flag(&soops->tree, TSE_SELECTED, 0); - + tselem->flag |= TSE_SELECTED; /* redraw, same as outliner_select function */ soops->storeflag |= SO_TREESTORE_REDRAW; ED_region_tag_redraw(ar); } - + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + if (scenelevel) { if (objectlevel || datalevel || idlevel) { BKE_report(reports, RPT_WARNING, "Mixed selection"); @@ -1927,10 +1927,10 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop } } } - + return 1; } - + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_operation_event(C, ar, soops, te, mval)) return 1; @@ -1952,13 +1952,13 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent } UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_operation_event(C, ar, soops, te, fmval)) { break; } } - + return OPERATOR_FINISHED; } @@ -1968,9 +1968,9 @@ void OUTLINER_OT_operation(wmOperatorType *ot) ot->name = "Execute Operation"; ot->idname = "OUTLINER_OT_operation"; ot->description = "Context menu for item operations"; - + ot->invoke = outliner_operation; - + ot->poll = ED_operator_outliner_active; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 6a4e9bc9578..b54a7705686 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -28,7 +28,7 @@ /** \file blender/editors/space_outliner/outliner_tree.c * \ingroup spoutliner */ - + #include #include @@ -89,11 +89,11 @@ static void outliner_storage_cleanup(SpaceOops *soops) { BLI_mempool *ts = soops->treestore; - + if (ts) { TreeStoreElem *tselem; int unused = 0; - + /* each element used once, for ID blocks with more users to have each a treestore */ BLI_mempool_iter iter; @@ -101,7 +101,7 @@ static void outliner_storage_cleanup(SpaceOops *soops) while ((tselem = BLI_mempool_iterstep(&iter))) { tselem->used = 0; } - + /* cleanup only after reading file or undo step, and always for * RNA datablocks view in order to save memory */ if (soops->storeflag & SO_TREESTORE_CLEANUP) { @@ -111,7 +111,7 @@ static void outliner_storage_cleanup(SpaceOops *soops) while ((tselem = BLI_mempool_iterstep(&iter))) { if (tselem->id == NULL) unused++; } - + if (unused) { if (BLI_mempool_len(ts) == unused) { BLI_mempool_destroy(ts); @@ -147,11 +147,11 @@ static void outliner_storage_cleanup(SpaceOops *soops) static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short type, short nr) { TreeStoreElem *tselem; - + if (soops->treestore == NULL) { /* if treestore was not created in readfile.c, create it here */ soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER); - + } if (soops->treehash == NULL) { soops->treehash = BKE_outliner_treehash_create_from_treestore(soops->treestore); @@ -184,10 +184,10 @@ void outliner_free_tree(ListBase *lb) { while (lb->first) { TreeElement *te = lb->first; - + outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - + if (te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } @@ -217,12 +217,12 @@ TreeElement *outliner_find_tse(SpaceOops *soops, const TreeStoreElem *tse) TreeStoreElem *tselem; if (tse->id == NULL) return NULL; - + /* check if 'tse' is in treestore */ tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); - if (tselem) + if (tselem) return outliner_find_tree_element(&soops->tree, tselem); - + return NULL; } @@ -289,7 +289,7 @@ ID *outliner_search_back(SpaceOops *UNUSED(soops), TreeElement *te, short idcode { TreeStoreElem *tselem; te = te->parent; - + while (te) { tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == idcode) return tselem->id; @@ -302,7 +302,7 @@ ID *outliner_search_back(SpaceOops *UNUSED(soops), TreeElement *te, short idcode /* ********************************************************* */ /* Prototype, see functions below */ -static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, +static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index); /* -------------------------------------------------------- */ @@ -312,11 +312,11 @@ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curB TreeElement *parent, int *a) { TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); - + (*a)++; te->name = curBone->name; te->directdata = curBone; - + for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } @@ -333,16 +333,16 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc /* log stuff is to convert bitflags (powers of 2) to small integers, * in order to not overflow short tselem->nr */ - + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); te->name = IFACE_("Combined"); te->directdata = &srl->passflag; - + /* save cpu cycles, but we add the first to invoke an open/close triangle */ tselem = TREESTORE(tenla); if (tselem->flag & TSE_CLOSED) return; - + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); te->name = IFACE_("Z"); te->directdata = &srl->passflag; @@ -454,27 +454,27 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s SceneRenderLayer *srl; TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); int a; - + tenla->name = IFACE_("RenderLayers"); for (a = 0, srl = sce->r.layers.first; srl; srl = srl->next, a++) { TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); tenlay->name = srl->name; tenlay->directdata = &srl->layflag; - + if (srl->light_override) outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); if (srl->mat_override) outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0); - + outliner_add_passes(soops, tenlay, &sce->id, srl); } - + // TODO: move this to the front? if (outliner_animdata_test(sce->adt)) outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, lb, sce->gpd, te, 0, 0); - + outliner_add_element(soops, lb, sce->world, te, 0, 0); #ifdef WITH_FREESTYLE @@ -488,41 +488,41 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree { if (outliner_animdata_test(ob->adt)) outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - + if (ob->proxy && !ID_IS_LINKED(ob)) outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); - + outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0); - + outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); - + if (ob->pose) { bArmature *arm = ob->data; bPoseChannel *pchan; TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); - + tenla->name = IFACE_("Pose"); - + /* channels undefined in editmode, but we want the 'tenla' pose icon itself */ if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { TreeElement *ten; int a = 0, const_index = 1000; /* ensure unique id for bone constraints */ - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) { ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); ten->name = pchan->name; ten->directdata = pchan; pchan->temp = (void *)ten; - + if (pchan->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten1; TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); //char *str; - + tenla1->name = IFACE_("Constraints"); for (con = pchan->constraints.first; con; con = con->next, const_index++) { ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); @@ -555,7 +555,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree ten = nten; } } - + /* Pose Groups */ if (ob->pose->agroups.first) { bActionGroup *agrp; @@ -571,11 +571,11 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree } } } - + for (int a = 0; a < ob->totcol; a++) { outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); } - + if (ob->constraints.first) { //Object *target; bConstraint *con; @@ -583,7 +583,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); //char *str; int a; - + tenla->name = IFACE_("Constraints"); for (con = ob->constraints.first, a = 0; con; con = con->next, a++) { ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); @@ -598,18 +598,18 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree /* possible add all other types links? */ } } - + if (ob->modifiers.first) { ModifierData *md; TreeElement *ten_mod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0); int index; - + ten_mod->name = IFACE_("Modifiers"); for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) { TreeElement *ten = outliner_add_element(soops, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index); ten->name = md->name; ten->directdata = md; - + if (md->type == eModifierType_Lattice) { outliner_add_element(soops, &ten->subtree, ((LatticeModifierData *) md)->object, ten, TSE_LINKED_OB, 0); } @@ -625,21 +625,21 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree else if (md->type == eModifierType_ParticleSystem) { ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys; TreeElement *ten_psys; - + ten_psys = outliner_add_element(soops, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0); ten_psys->directdata = psys; ten_psys->name = psys->part->id.name + 2; } } } - + /* vertex groups */ if (ob->defbase.first) { bDeformGroup *defgroup; TreeElement *ten; TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); int a; - + tenla->name = IFACE_("Vertex Groups"); for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) { ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); @@ -647,7 +647,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree ten->directdata = defgroup; } } - + /* duplicated group */ if (ob->dup_group) outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); @@ -659,7 +659,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { /* tuck pointer back in object, to construct hierarchy */ if (GS(id->name) == ID_OB) id->newid = (ID *)te; - + /* expand specific data always */ switch (GS(id->name)) { case ID_LI: @@ -681,10 +681,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Mesh *me = (Mesh *)id; int a; - + if (outliner_animdata_test(me->adt)) outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); for (a = 0; a < me->totcol; a++) outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); @@ -696,10 +696,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Curve *cu = (Curve *)id; int a; - + if (outliner_animdata_test(cu->adt)) outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < cu->totcol; a++) outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); break; @@ -708,10 +708,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { MetaBall *mb = (MetaBall *)id; int a; - + if (outliner_animdata_test(mb->adt)) outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < mb->totcol; a++) outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); break; @@ -720,10 +720,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Material *ma = (Material *)id; int a; - + if (outliner_animdata_test(ma->adt)) outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < MAX_MTEX; a++) { if (ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); } @@ -732,17 +732,17 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor case ID_TE: { Tex *tex = (Tex *)id; - + if (outliner_animdata_test(tex->adt)) outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); break; } case ID_CA: { Camera *ca = (Camera *)id; - + if (outliner_animdata_test(ca->adt)) outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); break; @@ -761,10 +761,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Lamp *la = (Lamp *)id; int a; - + if (outliner_animdata_test(la->adt)) outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < MAX_MTEX; a++) { if (la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); } @@ -782,10 +782,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { World *wrld = (World *)id; int a; - + if (outliner_animdata_test(wrld->adt)) outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < MAX_MTEX; a++) { if (wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); } @@ -794,7 +794,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor case ID_KE: { Key *key = (Key *)id; - + if (outliner_animdata_test(key->adt)) outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); break; @@ -809,14 +809,14 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { bArmature *arm = (bArmature *)id; int a = 0; - + if (outliner_animdata_test(arm->adt)) outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); - + if (arm->edbo) { EditBone *ebone; TreeElement *ten; - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) { ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); ten->directdata = ebone; @@ -856,7 +856,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id; int a; - + if (outliner_animdata_test(linestyle->adt)) outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0); @@ -871,10 +871,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor bGPdata *gpd = (bGPdata *)id; bGPDlayer *gpl; int a = 0; - + if (outliner_animdata_test(gpd->adt)) outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0); - + // TODO: base element for layers? for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a); @@ -895,7 +895,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i TreeElement *te; TreeStoreElem *tselem; ID *id = idv; - + if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id = ((PointerRNA *)idv)->id.data; if (!id) id = ((PointerRNA *)idv)->data; @@ -924,11 +924,11 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* add to the storage */ check_persistent(soops, te, id, type, index); tselem = TREESTORE(te); - + /* if we are searching for something expand to see child elements */ if (SEARCHING_OUTLINER(soops)) tselem->flag |= TSE_CHILDSEARCH; - + te->parent = parent; te->index = index; // for data arays if (ELEM(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { @@ -954,10 +954,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->name = id->name + 2; // default, can be overridden by Library or non-ID data te->idcode = GS(id->name); } - + if (type == 0) { TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL; - + /* ID datablock */ if (tsepar == NULL || tsepar->type != TSE_ID_BASE) outliner_add_id_contents(soops, te, tselem, id); @@ -965,30 +965,30 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; AnimData *adt = (AnimData *)iat->adt; - + /* this element's info */ te->name = IFACE_("Animation"); te->directdata = adt; - + /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); - + /* Drivers */ if (adt->drivers.first) { TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); ID *lastadded = NULL; FCurve *fcu; - + ted->name = IFACE_("Drivers"); - + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { if (fcu->driver && fcu->driver->variables.first) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* loop over all targets used here */ - DRIVER_TARGETS_USED_LOOPER(dvar) + DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... @@ -1001,23 +1001,23 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } } - + /* NLA Data */ if (adt->nla_tracks.first) { TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); NlaTrack *nlt; int a = 0; - + tenla->name = IFACE_("NLA Tracks"); - + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); NlaStrip *strip; TreeElement *ten; int b = 0; - + tenlt->name = nlt->name; - + for (strip = nlt->strips.first; strip; strip = strip->next, b++) { ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); if (ten) ten->directdata = strip; @@ -1027,7 +1027,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } else if (type == TSE_GP_LAYER) { bGPDlayer *gpl = (bGPDlayer *)idv; - + te->name = gpl->info; te->directdata = gpl; } @@ -1200,31 +1200,31 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i wmKeyMap *km = (wmKeyMap *)idv; wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; - + te->directdata = idv; te->name = km->idname; - + if (TSELEM_OPEN(tselem, soops)) { int a = 0; - + for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { const char *key = WM_key_event_string(kmi->type, false); - + if (key[0]) { wmOperatorType *ot = NULL; - + if (kmi->propvalue) { /* pass */ } else { ot = WM_operatortype_find(kmi->idname, 0); } - + if (ot || kmi->propvalue) { TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); - + ten->directdata = kmi; - + if (kmi->propvalue) { ten->name = IFACE_("Modal map, not yet"); } @@ -1237,7 +1237,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } } - else + else te->flag |= TE_LAZY_CLOSED; } @@ -1312,25 +1312,25 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE TreeElement *ten; ListBase *lbarray[MAX_LIBARRAY]; int a, tot; - + tot = set_listbasepointers(mainvar, lbarray); for (a = 0; a < tot; a++) { if (lbarray[a]->first) { ID *id = lbarray[a]->first; - + /* check if there's data in current lib */ for (; id; id = id->next) if (id->lib == lib) break; - + if (id) { ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0); ten->directdata = lbarray[a]; - + ten->name = BKE_idcode_to_name_plural(GS(id->name)); if (ten->name == NULL) ten->name = "UNKNOWN"; - + for (id = lbarray[a]->first; id; id = id->next) { if (id->lib == lib) outliner_add_element(soops, &ten->subtree, id, ten, 0, 0); @@ -1338,7 +1338,7 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE } } } - + } static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) @@ -1346,18 +1346,18 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) TreeElement *ten; ListBase *lbarray[MAX_LIBARRAY]; int a, tot; - + tot = set_listbasepointers(mainvar, lbarray); for (a = 0; a < tot; a++) { if (lbarray[a]->first) { ID *id = lbarray[a]->first; - + /* check if there are any datablocks of this type which are orphans */ for (; id; id = id->next) { if (ID_REAL_USERS(id) <= 0) break; } - + if (id) { /* header for this type of datablock */ /* TODO's: @@ -1366,11 +1366,11 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) */ ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0); ten->directdata = lbarray[a]; - + ten->name = BKE_idcode_to_name_plural(GS(id->name)); if (ten->name == NULL) ten->name = "UNKNOWN"; - + /* add the orphaned datablocks - these will not be added with any subtrees attached */ for (id = lbarray[a]->first; id; id = id->next) { if (ID_REAL_USERS(id) <= 0) @@ -1398,7 +1398,7 @@ static void outliner_make_hierarchy(ListBase *lb) while (te) { ten = te->next; tselem = TREESTORE(te); - + if (tselem->type == 0 && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { @@ -1427,16 +1427,16 @@ static int treesort_alpha_ob(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; - + /* first put objects last (hierarchy) */ comp = (x1->idcode == ID_OB); if (x2->idcode == ID_OB) comp += 2; - + if (comp == 1) return 1; else if (comp == 2) return -1; else if (comp == 3) { comp = strcmp(x1->name, x2->name); - + if (comp > 0) return 1; else if (comp < 0) return -1; return 0; @@ -1449,9 +1449,9 @@ static int treesort_alpha(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; - + comp = strcmp(x1->name, x2->name); - + if (comp > 0) return 1; else if (comp < 0) return -1; return 0; @@ -1463,7 +1463,7 @@ static int treesort_alpha(const void *v1, const void *v2) static int treesort_obtype_alpha(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; - + /* first put objects last (hierarchy) */ if (x1->idcode == ID_OB && x2->idcode != ID_OB) { return 1; @@ -1480,7 +1480,7 @@ static int treesort_obtype_alpha(const void *v1, const void *v2) } else { int comp = strcmp(x1->name, x2->name); - + if (comp > 0) return 1; else if (comp < 0) return -1; return 0; @@ -1499,13 +1499,13 @@ static void outliner_sort(ListBase *lb) te = lb->last; if (te == NULL) return; tselem = TREESTORE(te); - + /* sorting rules; only object lists, ID lists, or deformgroups */ if ( ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) { - + /* count first */ for (te = lb->first; te; te = te->next) totelem++; - + if (totelem > 1) { tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); tTreeSort *tp = tear; @@ -1516,15 +1516,15 @@ static void outliner_sort(ListBase *lb) tp->te = te; tp->name = te->name; tp->idcode = te->idcode; - + if (tselem->type && tselem->type != TSE_DEFGROUP) tp->idcode = 0; // don't sort this if (tselem->type == TSE_ID_BASE) tp->idcode = 1; // do sort this - + tp->id = tselem->id; } - + /* just sort alphabetically */ if (tear->idcode == 1) { qsort(tear, totelem, sizeof(tTreeSort), treesort_alpha); @@ -1533,11 +1533,11 @@ static void outliner_sort(ListBase *lb) /* keep beginning of list */ for (tp = tear, skip = 0; skip < totelem; skip++, tp++) if (tp->idcode) break; - + if (skip < totelem) qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); } - + BLI_listbase_clear(lb); tp = tear; while (totelem--) { @@ -1547,7 +1547,7 @@ static void outliner_sort(ListBase *lb) MEM_freeN(tear); } } - + for (te = lb->first; te; te = te->next) { outliner_sort(&te->subtree); } @@ -1572,7 +1572,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) char search_buff[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; char *search_string; - /* although we don't have any search string, we return true + /* although we don't have any search string, we return true * since the entire tree is ok then... */ if (soops->search_string[0] == 0) @@ -1589,7 +1589,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) for (te = lb->first; te; te = ten) { ten = te->next; - + if (!outliner_filter_has_name(te, search_string, soops->search_flags)) { /* item isn't something we're looking for, but... * - if the subtree is expanded, check if there are any matches that can be easily found @@ -1598,29 +1598,29 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) * so these can be safely ignored (i.e. the subtree can get freed) */ tselem = TREESTORE(te); - + /* flag as not a found item */ tselem->flag &= ~TSE_SEARCHMATCH; - + if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree) == 0) { outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - + if (te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } } else { tselem = TREESTORE(te); - + /* flag as a found item - we can then highlight it */ tselem->flag |= TSE_SEARCHMATCH; - + /* filter subtree too */ outliner_filter_tree(soops, &te->subtree); } } - + /* if there are still items in the list, that means that there were still some matches */ return (BLI_listbase_is_empty(lb) == false); } @@ -1655,11 +1655,11 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) outliner_free_tree(&soops->tree); outliner_storage_cleanup(soops); - + /* options */ if (soops->outlinevis == SO_LIBRARIES) { Library *lib; - + /* current file first - mainvar provides tselem with unique pointer - not used */ ten = outliner_add_element(soops, &soops->tree, mainvar, NULL, TSE_ID_BASE, 0); ten->name = IFACE_("Current File"); @@ -1667,13 +1667,13 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) tselem = TREESTORE(ten); if (!tselem->used) tselem->flag &= ~TSE_CLOSED; - + outliner_add_library_contents(mainvar, soops, ten, NULL); - + for (lib = mainvar->library.first; lib; lib = lib->id.next) { ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); lib->id.newid = (ID *)ten; - + outliner_add_library_contents(mainvar, soops, ten, lib); } @@ -1704,7 +1704,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) /* restore newid pointers */ for (lib = mainvar->library.first; lib; lib = lib->id.next) lib->id.newid = NULL; - + } else if (soops->outlinevis == SO_ALL_SCENES) { Scene *sce; @@ -1713,7 +1713,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) tselem = TREESTORE(te); if (sce == scene && show_opened) tselem->flag &= ~TSE_CLOSED; - + for (base = sce->base.first; base; base = base->next) { ten = outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); ten->directdata = base; @@ -1724,9 +1724,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) } } else if (soops->outlinevis == SO_CUR_SCENE) { - + outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - + for (base = scene->base.first; base; base = base->next) { ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); ten->directdata = base; @@ -1743,11 +1743,11 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) else if (soops->outlinevis == SO_GROUPS) { Group *group; GroupObject *go; - + for (group = mainvar->group.first; group; group = group->id.next) { if (group->gobject.first) { te = outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - + for (go = group->gobject.first; go; go = go->next) { ten = outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); ten->directdata = NULL; /* eh, why? */ diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index cb6d67390a0..0cf4fd09555 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -66,7 +66,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) { ListBase *lb; wmKeyMap *keymap; - + /* make sure we keep the hide flags */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP); /* prevent any noise of past */ @@ -79,7 +79,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */ @@ -270,16 +270,16 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) { View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - + /* clear */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + draw_outliner(C); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -289,7 +289,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) static void outliner_main_region_free(ARegion *UNUSED(ar)) { - + } static void outliner_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) @@ -393,7 +393,7 @@ static void outliner_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s ED_region_tag_redraw(ar); break; } - + } @@ -438,20 +438,20 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner"); soutliner->spacetype = SPACE_OUTLINER; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for outliner"); - + BLI_addtail(&soutliner->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for outliner"); - + BLI_addtail(&soutliner->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + return (SpaceLink *)soutliner; } @@ -459,7 +459,7 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) static void outliner_free(SpaceLink *sl) { SpaceOops *soutliner = (SpaceOops *)sl; - + outliner_free_tree(&soutliner->tree); if (soutliner->treestore) { BLI_mempool_destroy(soutliner->treestore); @@ -472,7 +472,7 @@ static void outliner_free(SpaceLink *sl) /* spacetype; init callback */ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) { - + } static SpaceLink *outliner_duplicate(SpaceLink *sl) @@ -483,7 +483,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) BLI_listbase_clear(&soutlinern->tree); soutlinern->treestore = NULL; soutlinern->treehash = NULL; - + return (SpaceLink *)soutlinern; } @@ -525,10 +525,10 @@ void ED_spacetype_outliner(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - + st->spaceid = SPACE_OUTLINER; strncpy(st->name, "Outliner", BKE_ST_MAXNAME); - + st->new = outliner_new; st->free = outliner_free; st->init = outliner_init; @@ -542,25 +542,25 @@ void ED_spacetype_outliner(void) art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; - + art->init = outliner_main_region_init; art->draw = outliner_main_region_draw; art->free = outliner_main_region_free; art->listener = outliner_main_region_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = outliner_header_region_init; art->draw = outliner_header_region_draw; art->free = outliner_header_region_free; art->listener = outliner_header_region_listener; BLI_addhead(&st->regiontypes, art); - + BKE_spacetype_register(st); } -- cgit v1.2.3