From ce3b78c73a7ccc16fdccf7decedb5d1578dfdf0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Mar 2019 21:16:47 +1100 Subject: Cleanup: style, use braces for editor/spaces --- .../editors/space_outliner/outliner_dragdrop.c | 69 ++++-- .../blender/editors/space_outliner/outliner_draw.c | 62 +++-- .../blender/editors/space_outliner/outliner_edit.c | 151 ++++++++---- .../editors/space_outliner/outliner_select.c | 38 ++- .../editors/space_outliner/outliner_tools.c | 105 +++++--- .../blender/editors/space_outliner/outliner_tree.c | 263 ++++++++++++++------- .../editors/space_outliner/outliner_utils.c | 19 +- .../editors/space_outliner/space_outliner.c | 21 +- 8 files changed, 507 insertions(+), 221 deletions(-) (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index d9dc0d182c7..77821ec0990 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -73,15 +73,17 @@ static TreeElement *outliner_dropzone_element(TreeElement *te, const float fmval { if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* name and first icon */ - if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) + if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { return te; + } } /* Not it. Let's look at its children. */ if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { TreeElement *te_valid = outliner_dropzone_element(te, fmval, children); - if (te_valid) + if (te_valid) { return te_valid; + } } } return NULL; @@ -94,8 +96,9 @@ static TreeElement *outliner_dropzone_find(const SpaceOutliner *soops, const flo for (te = soops->tree.first; te; te = te->next) { TreeElement *te_valid = outliner_dropzone_element(te, fmval, children); - if (te_valid) + if (te_valid) { return te_valid; + } } return NULL; } @@ -204,11 +207,15 @@ static TreeElement *outliner_drop_insert_collection_find( TreeElementInsertType *r_insert_type) { TreeElement *te = outliner_drop_insert_find(C, event, r_insert_type); - if (!te) return NULL; + if (!te) { + return NULL; + } TreeElement *collection_te; Collection *collection = outliner_collection_from_tree_element_and_parents(te, &collection_te); - if (!collection) return NULL; + if (!collection) { + return NULL; + } if (collection_te != te) { *r_insert_type = TE_INSERT_INTO; @@ -233,9 +240,15 @@ static bool parent_drop_allowed(SpaceOutliner *soops, TreeElement *te, Object *p Object *potential_parent = (Object *)tselem->id; - if (potential_parent == potential_child) return false; - if (BKE_object_is_child_recursive(potential_child, potential_parent)) return false; - if (potential_parent == potential_child->parent) return false; + if (potential_parent == potential_child) { + return false; + } + if (BKE_object_is_child_recursive(potential_child, potential_parent)) { + return false; + } + if (potential_parent == potential_child->parent) { + return false; + } /* check that parent/child are both in the same scene */ Scene *scene = (Scene *)outliner_search_back(soops, te, ID_SCE); @@ -276,17 +289,25 @@ static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, co SpaceOutliner *soops = CTX_wm_space_outliner(C); bool changed = outliner_flag_set(&soops->tree, TSE_DRAG_ANY, false); - if (changed) ED_region_tag_redraw_no_rebuild(CTX_wm_region(C)); + if (changed) { + ED_region_tag_redraw_no_rebuild(CTX_wm_region(C)); + } Object *potential_child = (Object *)WM_drag_ID(drag, ID_OB); - if (!potential_child) return false; + if (!potential_child) { + return false; + } if (!allow_parenting_without_modifier_key(soops)) { - if (!event->shift) return false; + if (!event->shift) { + return false; + } } TreeElement *te = outliner_drop_find(C, event); - if (!te) return false; + if (!te) { + return false; + } if (parent_drop_allowed(soops, te, potential_child)) { TREESTORE(te)->flag |= TSE_DRAG_INTO; @@ -476,18 +497,26 @@ static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event, c SpaceOutliner *soops = CTX_wm_space_outliner(C); if (!allow_parenting_without_modifier_key(soops)) { - if (!event->shift) return false; + if (!event->shift) { + return false; + } } Object *ob = (Object *)WM_drag_ID(drag, ID_OB); - if (!ob) return false; - if (!ob->parent) return false; + if (!ob) { + return false; + } + if (!ob->parent) { + return false; + } TreeElement *te = outliner_drop_find(C, event); if (te) { TreeStoreElem *tselem = TREESTORE(te); ID *id = tselem->id; - if (!id) return true; + if (!id) { + return true; + } switch (GS(id->name)) { case ID_OB: @@ -772,11 +801,15 @@ static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event break; } } - if (changed) ED_region_tag_redraw_no_rebuild(ar); + if (changed) { + ED_region_tag_redraw_no_rebuild(ar); + } return true; } else { - if (changed) ED_region_tag_redraw_no_rebuild(ar); + if (changed) { + ED_region_tag_redraw_no_rebuild(ar); + } return false; } } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 929c179a62f..99d4c587401 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -125,8 +125,9 @@ static void outliner_rna_width(SpaceOutliner *soops, ListBase *lb, int *w, int s *w = te->xend; } #endif - if (startx + 100 > *w) + if (startx + 100 > *w) { *w = startx + 100; + } if (TSELEM_OPEN(tselem, soops)) { outliner_rna_width(soops, &te->subtree, w, startx + UI_UNIT_X); @@ -194,8 +195,9 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2) static void restrictbutton_bone_visibility_cb(bContext *C, void *UNUSED(poin), void *poin2) { Bone *bone = (Bone *)poin2; - if (bone->flag & BONE_HIDDEN_P) + if (bone->flag & BONE_HIDDEN_P) { bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_bone(bone, BONE_HIDDEN_P, (bone->flag & BONE_HIDDEN_P) != 0); @@ -207,8 +209,9 @@ static void restrictbutton_bone_visibility_cb(bContext *C, void *UNUSED(poin), v static void restrictbutton_bone_select_cb(bContext *C, void *UNUSED(poin), void *poin2) { Bone *bone = (Bone *)poin2; - if (bone->flag & BONE_UNSELECTABLE) + if (bone->flag & BONE_UNSELECTABLE) { bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_bone(bone, BONE_UNSELECTABLE, (bone->flag & BONE_UNSELECTABLE) != 0); @@ -800,8 +803,9 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s char buf[16] = ""; int but_flag = UI_BUT_DRAG_LOCK; - if (ID_IS_LINKED(id)) + if (ID_IS_LINKED(id)) { but_flag |= UI_BUT_DISABLED; + } if (id->flag & LIB_FAKEUSER) { icon = ICON_FILE_TICK; @@ -850,7 +854,9 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) View2D *v2d = &ar->v2d; float miny = v2d->cur.ymin; - if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; + if (miny < v2d->tot.ymin) { + miny = v2d->tot.ymin; + } GPU_line_width(1.0f); @@ -931,10 +937,18 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Tre * need change this. */ - if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name); - else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name); - else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name); - else len = MAX_ID_NAME - 2; + if (tselem->type == TSE_EBONE) { + len = sizeof(((EditBone *) 0)->name); + } + else if (tselem->type == TSE_MODIFIER) { + len = sizeof(((ModifierData *) 0)->name); + } + else if (tselem->id && GS(tselem->id->name) == ID_LI) { + len = sizeof(((Library *) 0)->name); + } + else { + len = MAX_ID_NAME - 2; + } spx = te->xs + 1.8f * UI_UNIT_X; dx = ar->v2d.cur.xmax - (spx + 3.2f * UI_UNIT_X); @@ -1240,18 +1254,24 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) data.icon = ICON_GROUP_BONE; break; case TSE_SEQUENCE: - if (te->idcode == SEQ_TYPE_MOVIE) + if (te->idcode == SEQ_TYPE_MOVIE) { data.icon = ICON_SEQUENCE; - else if (te->idcode == SEQ_TYPE_META) + } + else if (te->idcode == SEQ_TYPE_META) { data.icon = ICON_DOT; - else if (te->idcode == SEQ_TYPE_SCENE) + } + else if (te->idcode == SEQ_TYPE_SCENE) { data.icon = ICON_SCENE; - else if (te->idcode == SEQ_TYPE_SOUND_RAM) + } + else if (te->idcode == SEQ_TYPE_SOUND_RAM) { data.icon = ICON_SOUND; - else if (te->idcode == SEQ_TYPE_IMAGE) + } + else if (te->idcode == SEQ_TYPE_IMAGE) { data.icon = ICON_IMAGE; - else + } + else { data.icon = ICON_PARTICLES; + } break; case TSE_SEQ_STRIP: data.icon = ICON_LIBRARY_DATA_DIRECT; @@ -1601,8 +1621,9 @@ static void outliner_draw_iconrow( for (TreeElement *te = lb->first; te; te = te->next) { /* exit drawing early */ - if ((*offsx) - UI_UNIT_X > xmax) + if ((*offsx) - UI_UNIT_X > xmax) { break; + } TreeStoreElem *tselem = TREESTORE(te); @@ -1710,8 +1731,9 @@ 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) + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) { xmax -= OL_TOGW + UI_UNIT_X; + } GPU_blend(true); @@ -1808,8 +1830,9 @@ static void outliner_draw_tree_element( tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac, true); offsx += UI_UNIT_X + 4 * ufac; } - else + else { offsx += 2 * ufac; + } if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_LINKED(tselem->id)) { if (tselem->id->tag & LIB_TAG_MISSING) { @@ -1965,10 +1988,11 @@ static void outliner_draw_hierarchy_lines_recursive( *starty -= UI_UNIT_Y; - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { outliner_draw_hierarchy_lines_recursive( pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_childs_grayed_out, starty); + } } if (draw_grayed_out) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 0cadda235f4..aa9c462d74e 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -141,16 +141,21 @@ static int do_outliner_item_openclose(bContext *C, SpaceOutliner *soops, TreeEle outliner_flag_set(&te->subtree, TSE_CLOSED, !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1)); } else { - if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; + 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; @@ -168,8 +173,9 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e 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); @@ -308,7 +314,9 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement } for (te = te->subtree.first; te; te = te->next) { - if (do_outliner_item_rename(reports, ar, te, mval)) return 1; + if (do_outliner_item_rename(reports, ar, te, mval)) { + return 1; + } } return 0; } @@ -865,7 +873,9 @@ static int outliner_count_levels(ListBase *lb, const int curlevel) for (te = lb->first; te; te = te->next) { lev = outliner_count_levels(&te->subtree, curlevel + 1); - if (lev > level) level = lev; + if (lev > level) { + level = lev; + } } return level; } @@ -878,10 +888,14 @@ int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel) for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - if (tselem->flag & flag) return curlevel; + if (tselem->flag & flag) { + return curlevel; + } level = outliner_flag_is_any_test(&te->subtree, flag, curlevel + 1); - if (level) return level; + if (level) { + return level; + } } return 0; } @@ -944,11 +958,13 @@ int common_restrict_check(bContext *C, Object *ob) Object *obedit = CTX_data_edit_object(C); if (obedit && obedit == ob) { /* found object is hidden, reset */ - if (ob->restrictflag & OB_RESTRICT_VIEW) + if (ob->restrictflag & OB_RESTRICT_VIEW) { ob->restrictflag &= ~OB_RESTRICT_VIEW; + } /* found object is unselectable, reset */ - if (ob->restrictflag & OB_RESTRICT_SELECT) + if (ob->restrictflag & OB_RESTRICT_SELECT) { ob->restrictflag &= ~OB_RESTRICT_SELECT; + } return 0; } @@ -965,10 +981,12 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOutliner *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); - if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) + if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) { outliner_flag_set(&soops->tree, TSE_CLOSED, 0); - else + } + else { outliner_flag_set(&soops->tree, TSE_CLOSED, 1); + } ED_region_tag_redraw(ar); @@ -1098,8 +1116,9 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) Object *obact = OBACT(view_layer); - if (!obact) + if (!obact) { return OPERATOR_CANCELLED; + } te = outliner_find_id(so, &so->tree, &obact->id); @@ -1130,7 +1149,9 @@ 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; + if (ytop > 0) { + ytop = 0; + } v2d->cur.ymax = (float)ytop; v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); @@ -1166,10 +1187,13 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op) int dy = BLI_rcti_size_y(&ar->v2d.mask); int up = 0; - if (RNA_boolean_get(op->ptr, "up")) + if (RNA_boolean_get(op->ptr, "up")) { up = 1; + } - if (up == 0) dy = -dy; + if (up == 0) { + dy = -dy; + } ar->v2d.cur.ymin += dy; ar->v2d.cur.ymax += dy; @@ -1319,10 +1343,14 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int tselem = TREESTORE(te); if (open) { - if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; + if (curlevel <= level) { + tselem->flag &= ~TSE_CLOSED; + } } else { - if (curlevel >= level) tselem->flag |= TSE_CLOSED; + if (curlevel >= level) { + tselem->flag |= TSE_CLOSED; + } } outliner_openclose_level(&te->subtree, curlevel + 1, level, open); @@ -1338,11 +1366,17 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) level = outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1); if (add == 1) { - if (level) outliner_openclose_level(&soops->tree, 1, level, 1); + if (level) { + outliner_openclose_level(&soops->tree, 1, level, 1); + } } else { - if (level == 0) level = outliner_count_levels(&soops->tree, 0); - if (level) outliner_openclose_level(&soops->tree, 1, level - 1, 0); + 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); @@ -1380,8 +1414,12 @@ static int subtree_has_objects(ListBase *lb) for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - if (tselem->type == 0 && te->idcode == ID_OB) return 1; - if (subtree_has_objects(&te->subtree)) return 1; + if (tselem->type == 0 && te->idcode == ID_OB) { + return 1; + } + if (subtree_has_objects(&te->subtree)) { + return 1; + } } return 0; } @@ -1398,12 +1436,20 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *soops, List if (tselem->type == 0) { if (te->idcode == ID_SCE) { - if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; - else tselem->flag &= ~TSE_CLOSED; + if (tselem->id != (ID *)scene) { + tselem->flag |= TSE_CLOSED; + } + else { + tselem->flag &= ~TSE_CLOSED; + } } else if (te->idcode == ID_OB) { - if (subtree_has_objects(&te->subtree)) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; + if (subtree_has_objects(&te->subtree)) { + tselem->flag &= ~TSE_CLOSED; + } + else { + tselem->flag |= TSE_CLOSED; + } } } else { @@ -1479,8 +1525,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed */ - if (tselem->type == TSE_RNA_STRUCT) + 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 @@ -1530,17 +1577,19 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* if possible, use name as a key in the path */ newpath = RNA_path_append(*path, NULL, prop, 0, name); - if (name != buf) + 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) + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) { + if (temsub == temnext) { break; - + } + } newpath = RNA_path_append(*path, NULL, prop, index, NULL); } @@ -1549,7 +1598,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, } if (newpath) { - if (*path) MEM_freeN(*path); + if (*path) { + MEM_freeN(*path); + } *path = newpath; newpath = NULL; } @@ -1590,7 +1641,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* path */ newpath = RNA_path_append(*path, NULL, prop, 0, NULL); - if (*path) MEM_freeN(*path); + if (*path) { + MEM_freeN(*path); + } *path = newpath; } @@ -1647,12 +1700,14 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops, ListBase *tree, Rep /* entire array was selected, so add drivers for all */ arraylen = RNA_property_array_length(&te->rnaptr, te->directdata); } - else + else { arraylen = array_index; + } /* we should do at least one step */ - if (arraylen == array_index) + if (arraylen == array_index) { arraylen++; + } /* for each array element we should affect, add driver */ for (; array_index < arraylen; array_index++) { @@ -1681,8 +1736,9 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops, ListBase *tree, Rep } /* go over sub-tree */ - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { do_outliner_drivers_editop(soops, &te->subtree, reports, mode); + } } } @@ -1693,8 +1749,9 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) SpaceOutliner *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ - if (soutliner == NULL) + 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); @@ -1728,8 +1785,9 @@ static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) SpaceOutliner *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ - if (soutliner == NULL) + 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); @@ -1775,12 +1833,14 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) KeyingSet *ks = NULL; /* sanity check */ - if (scene == NULL) + if (scene == NULL) { return NULL; + } /* try to find one from scene */ - if (scene->active_keyingset > 0) + 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 @@ -1852,8 +1912,9 @@ static void do_outliner_keyingset_editop(SpaceOutliner *soops, KeyingSet *ks, Li } /* go over sub-tree */ - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { do_outliner_keyingset_editop(soops, ks, &te->subtree, mode); + } } } @@ -1870,8 +1931,9 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set"); return OPERATOR_CANCELLED; } - if (soutliner == NULL) + if (soutliner == NULL) { return OPERATOR_CANCELLED; + } /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); @@ -1907,8 +1969,9 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ - if (soutliner == NULL) + if (soutliner == NULL) { return OPERATOR_CANCELLED; + } /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index a1afe8b46ea..5ace2c291e0 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -227,8 +227,9 @@ static eOLDrawState active_viewlayer( bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, const eOLSetState set) { /* paranoia check */ - if (te->idcode != ID_SCE) + if (te->idcode != ID_SCE) { return OL_DRAWSEL_NONE; + } ViewLayer *view_layer = te->directdata; @@ -268,10 +269,12 @@ static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, { Bone *bone; for (bone = bone_parent->childbase.first; bone; bone = bone->next) { - if (select && PBONE_SELECTABLE(arm, bone)) + if (select && PBONE_SELECTABLE(arm, bone)) { bone->flag |= BONE_SELECTED; - else + } + else { bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + } do_outliner_bone_select_recursive(arm, bone, select); } } @@ -281,10 +284,12 @@ static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_p EditBone *ebone; for (ebone = ebone_parent->next; ebone; ebone = ebone->next) { if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) { - if (select && EBONE_SELECTABLE(arm, ebone)) + if (select && EBONE_SELECTABLE(arm, ebone)) { ebone->flag |= BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL; - else + } + else { ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + } } } } @@ -341,10 +346,12 @@ static eOLDrawState tree_element_set_active_object( if (base) { if (set == OL_SETSEL_EXTEND) { /* swap select */ - if (base->flag & BASE_SELECTED) + if (base->flag & BASE_SELECTED) { ED_object_base_select(base, BA_DESELECT); - else + } + else { ED_object_base_select(base, BA_SELECT); + } } else { /* deleselect all */ @@ -477,8 +484,9 @@ static eOLDrawState tree_element_active_world( tep = te->parent; if (tep) { tselem = TREESTORE(tep); - if (tselem->type == 0) + if (tselem->type == 0) { sce = (Scene *)tselem->id; + } } if (set != OL_SETSEL_NONE) { @@ -578,8 +586,9 @@ static eOLDrawState tree_element_active_posechannel( if (set != OL_SETSEL_EXTEND) { bPoseChannel *pchannel; /* single select forces all other bones to get unselected */ - for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next) + for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next) { pchannel->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + } } if ((set == OL_SETSEL_EXTEND) && (pchan->bone->flag & BONE_SELECTED)) { @@ -665,12 +674,16 @@ static void tree_element_active_ebone__sel(bContext *C, Object *obedit, bArmatur ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL; arm->act_edbone = ebone; // flush to parent? - if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { + ebone->parent->flag |= BONE_TIPSEL; + } } else { ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); // flush to parent? - if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { + ebone->parent->flag &= ~BONE_TIPSEL; + } } WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, obedit); @@ -830,8 +843,9 @@ static eOLDrawState tree_element_active_sequence_dup( seq = (Sequence *)te->directdata; if (set == OL_SETSEL_NONE) { - if (seq->flag & SELECT) + if (seq->flag & SELECT) { return OL_DRAWSEL_NORMAL; + } return OL_DRAWSEL_NONE; } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 400a69cef51..15d2d007ecf 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -101,10 +101,12 @@ static void set_operation_types(SpaceOutliner *soops, ListBase *lb, if (tselem->flag & TSE_SELECTED) { /* Layer collection points to collection ID. */ if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) { - if (*datalevel == 0) + if (*datalevel == 0) { *datalevel = tselem->type; - else if (*datalevel != tselem->type) + } + else if (*datalevel != tselem->type) { *datalevel = -1; + } } else { int idcode = GS(tselem->id->name); @@ -122,8 +124,12 @@ static void set_operation_types(SpaceOutliner *soops, ListBase *lb, case ID_SO: case ID_KE: case ID_WO: case ID_AC: case ID_NLA: case ID_TXT: case ID_GR: case ID_LS: case ID_LI: - if (*idlevel == 0) *idlevel = idcode; - else if (*idlevel != idcode) *idlevel = -1; + if (*idlevel == 0) { + *idlevel = idcode; + } + else if (*idlevel != idcode) { + *idlevel = -1; + } if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) { *datalevel = 0; } @@ -626,8 +632,9 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; - if (fcu->driver) + if (fcu->driver) { fcu->driver->flag &= ~DRIVER_FLAG_INVALID; + } } } @@ -657,48 +664,57 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), { bPoseChannel *pchan = (bPoseChannel *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { pchan->bone->flag |= BONE_SELECTED; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { pchan->bone->flag &= ~BONE_SELECTED; + } else if (event == OL_DOP_HIDE) { pchan->bone->flag |= BONE_HIDDEN_P; pchan->bone->flag &= ~BONE_SELECTED; } - else if (event == OL_DOP_UNHIDE) + else if (event == OL_DOP_UNHIDE) { pchan->bone->flag &= ~BONE_HIDDEN_P; + } } static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { Bone *bone = (Bone *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { bone->flag |= BONE_SELECTED; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { bone->flag &= ~BONE_SELECTED; + } else if (event == OL_DOP_HIDE) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; } - else if (event == OL_DOP_UNHIDE) + else if (event == OL_DOP_UNHIDE) { bone->flag &= ~BONE_HIDDEN_P; + } } static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { EditBone *ebone = (EditBone *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { ebone->flag |= BONE_SELECTED; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { ebone->flag &= ~BONE_SELECTED; + } else if (event == OL_DOP_HIDE) { ebone->flag |= BONE_HIDDEN_A; ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } - else if (event == OL_DOP_UNHIDE) + else if (event == OL_DOP_UNHIDE) { ebone->flag &= ~BONE_HIDDEN_A; + } } static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr) @@ -719,14 +735,18 @@ static void gp_layer_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem { bGPDlayer *gpl = (bGPDlayer *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { gpl->flag |= GP_LAYER_SELECT; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { gpl->flag &= ~GP_LAYER_SELECT; - else if (event == OL_DOP_HIDE) + } + else if (event == OL_DOP_HIDE) { gpl->flag |= GP_LAYER_HIDE; - else if (event == OL_DOP_UNHIDE) + } + else if (event == OL_DOP_UNHIDE) { gpl->flag &= ~GP_LAYER_HIDE; + } } static void data_select_linked_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v) @@ -839,7 +859,9 @@ static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *s for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) { base_next = child_base->next; - for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent); + for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent) { + /* pass */ + } if (parent) { base_next = outline_delete_hierarchy(C, reports, scene, child_base); } @@ -877,7 +899,9 @@ static void object_delete_hierarchy_cb( } if (base) { /* Check also library later. */ - for (; obedit && (obedit != base->object); obedit = obedit->parent); + for (; obedit && (obedit != base->object); obedit = obedit->parent) { + /* pass */ + } if (obedit == base->object) { ED_object_editmode_exit(C, EM_FREEDATA); } @@ -907,7 +931,9 @@ static Base *outline_batch_delete_hierarchy( object = base->object; for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) { base_next = child_base->next; - for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent); + for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent) { + /* pass */ + } if (parent) { base_next = outline_batch_delete_hierarchy(reports, bmain, view_layer, scene, child_base); } @@ -951,7 +977,9 @@ static void object_batch_delete_hierarchy_cb( } if (base) { /* Check also library later. */ - for (; obedit && (obedit != base->object); obedit = obedit->parent); + for (; obedit && (obedit != base->object); obedit = obedit->parent) { + /* pass */ + } if (obedit == base->object) { ED_object_editmode_exit(C, EM_FREEDATA); } @@ -1008,8 +1036,9 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) const char *str = NULL; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } event = RNA_enum_get(op->ptr, "type"); @@ -1215,8 +1244,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) eOutlinerIdOpTypes event; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); @@ -1429,8 +1459,9 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op) eOutlinerLibOpTypes event; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); @@ -1544,8 +1575,9 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) bAction *act; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); /* get action to use */ @@ -1565,12 +1597,15 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) } /* perform action if valid channel */ - if (datalevel == TSE_ANIM_DATA) + if (datalevel == TSE_ANIM_DATA) { outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); - else if (idlevel == ID_AC) + } + else if (idlevel == ID_AC) { outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); - else + } + else { return OPERATOR_CANCELLED; + } /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); @@ -1641,14 +1676,16 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) short updateDeps = 0; /* check for invalid states */ - if (soops == NULL) + 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) + if (datalevel != TSE_ANIM_DATA) { return OPERATOR_CANCELLED; + } /* perform the core operation */ switch (event) { @@ -1828,8 +1865,9 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) eOutliner_PropDataOps event; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); @@ -1942,8 +1980,9 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOutliner * /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) + if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) { outliner_flag_set(&soops->tree, TSE_SELECTED, 0); + } tselem->flag |= TSE_SELECTED; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 7d700be0ec7..72e9236636e 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -113,7 +113,9 @@ static void outliner_storage_cleanup(SpaceOutliner *soops) BLI_mempool_iternew(ts, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { - if (tselem->id == NULL) unused++; + if (tselem->id == NULL) { + unused++; + } } if (unused) { @@ -246,8 +248,9 @@ static void outliner_add_bone(SpaceOutliner *soops, ListBase *lb, ID *id, Bone * static bool outliner_animdata_test(AnimData *adt) { - if (adt) + if (adt) { return (adt->action || adt->drivers.first || adt->nla_tracks.first); + } return false; } @@ -269,8 +272,9 @@ static void outliner_add_line_styles(SpaceOutliner *soops, ListBase *lb, Scene * for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { FreestyleLineStyle *linestyle = lineset->linestyle; if (linestyle) { - if (!(linestyle->id.tag & LIB_TAG_DOIT)) + if (!(linestyle->id.tag & LIB_TAG_DOIT)) { continue; + } linestyle->id.tag &= ~LIB_TAG_DOIT; outliner_add_element(soops, lb, linestyle, te, 0, 0); } @@ -308,21 +312,24 @@ static void outliner_add_scene_contents(SpaceOutliner *soops, ListBase *lb, Scen outliner_make_object_parent_hierarchy(&ten->subtree); /* Animation Data */ - if (outliner_animdata_test(sce->adt)) + if (outliner_animdata_test(sce->adt)) { outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); + } } // can be inlined if necessary static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob) { - if (outliner_animdata_test(ob->adt)) + 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)) + 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); @@ -479,8 +486,9 @@ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, } /* duplicated group */ - if (ob->instance_collection) + if (ob->instance_collection) { outliner_add_element(soops, &te->subtree, ob->instance_collection, te, 0, 0); + } } @@ -488,7 +496,9 @@ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) { /* tuck pointer back in object, to construct hierarchy */ - if (GS(id->name) == ID_OB) id->newid = (ID *)te; + if (GS(id->name) == ID_OB) { + id->newid = (ID *)te; + } /* expand specific data always */ switch (GS(id->name)) { @@ -512,12 +522,14 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree Mesh *me = (Mesh *)id; int a; - if (outliner_animdata_test(me->adt)) + 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++) + for (a = 0; a < me->totcol; a++) { outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); + } /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ break; @@ -527,11 +539,13 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree Curve *cu = (Curve *)id; int a; - if (outliner_animdata_test(cu->adt)) + 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++) + for (a = 0; a < cu->totcol; a++) { outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); + } break; } case ID_MB: @@ -539,28 +553,31 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree MetaBall *mb = (MetaBall *)id; int a; - if (outliner_animdata_test(mb->adt)) + 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++) + for (a = 0; a < mb->totcol; a++) { outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); + } break; } case ID_MA: { Material *ma = (Material *)id; - if (outliner_animdata_test(ma->adt)) + if (outliner_animdata_test(ma->adt)) { outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); + } break; } case ID_TE: { Tex *tex = (Tex *)id; - if (outliner_animdata_test(tex->adt)) + 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; } @@ -568,8 +585,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree { Camera *ca = (Camera *)id; - if (outliner_animdata_test(ca->adt)) + if (outliner_animdata_test(ca->adt)) { outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); + } break; } case ID_CF: @@ -586,40 +604,45 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree { Light *la = (Light *)id; - if (outliner_animdata_test(la->adt)) + if (outliner_animdata_test(la->adt)) { outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); + } break; } case ID_SPK: { Speaker *spk = (Speaker *)id; - if (outliner_animdata_test(spk->adt)) + if (outliner_animdata_test(spk->adt)) { outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); + } break; } case ID_LP: { LightProbe *prb = (LightProbe *)id; - if (outliner_animdata_test(prb->adt)) + if (outliner_animdata_test(prb->adt)) { outliner_add_element(soops, &te->subtree, prb, te, TSE_ANIM_DATA, 0); + } break; } case ID_WO: { World *wrld = (World *)id; - if (outliner_animdata_test(wrld->adt)) + if (outliner_animdata_test(wrld->adt)) { outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); + } break; } case ID_KE: { Key *key = (Key *)id; - if (outliner_animdata_test(key->adt)) + if (outliner_animdata_test(key->adt)) { outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); + } break; } case ID_AC: @@ -633,8 +656,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree bArmature *arm = (bArmature *)id; int a = 0; - if (outliner_animdata_test(arm->adt)) + if (outliner_animdata_test(arm->adt)) { outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); + } if (arm->edbo) { EditBone *ebone; @@ -680,12 +704,14 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id; int a; - if (outliner_animdata_test(linestyle->adt)) + if (outliner_animdata_test(linestyle->adt)) { outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0); + } for (a = 0; a < MAX_MTEX; a++) { - if (linestyle->mtex[a]) + if (linestyle->mtex[a]) { outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a); + } } break; } @@ -695,8 +721,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree bGPDlayer *gpl; int a = 0; - if (outliner_animdata_test(gpd->adt)) + 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.last; gpl; gpl = gpl->prev) { @@ -729,7 +756,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id = ((PointerRNA *)idv)->id.data; - if (!id) id = ((PointerRNA *)idv)->data; + if (!id) { + id = ((PointerRNA *)idv)->data; + } } else if (type == TSE_GP_LAYER) { /* idv is the layer its self */ @@ -757,8 +786,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi tselem = TREESTORE(te); /* if we are searching for something expand to see child elements */ - if (SEARCHING_OUTLINER(soops)) + if (SEARCHING_OUTLINER(soops)) { tselem->flag |= TSE_CHILDSEARCH; + } te->parent = parent; te->index = index; // for data arrays @@ -782,10 +812,12 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi } else { /* do here too, for blend file viewer, own ID_LI then shows file name */ - if (GS(id->name) == ID_LI) + if (GS(id->name) == ID_LI) { te->name = ((Library *)id)->name; - else + } + else { te->name = id->name + 2; // default, can be overridden by Library or non-ID data + } te->idcode = GS(id->name); } @@ -855,7 +887,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi 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; + if (ten) { + ten->directdata = strip; + } } } } @@ -893,17 +927,20 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi p = p->next; } } - else + else { outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index); + } } } else if (type == TSE_SEQ_STRIP) { Strip *strip = (Strip *)idv; - if (strip->dir[0] != '\0') + if (strip->dir[0] != '\0') { te->name = strip->dir; - else + } + else { te->name = IFACE_("Strip None"); + } te->directdata = strip; } else if (type == TSE_SEQUENCE_DUP) { @@ -934,22 +971,28 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi /* struct */ te->name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); - if (te->name) + if (te->name) { te->flag |= TE_FREE_NAME; - else + } + else { te->name = RNA_struct_ui_name(ptr->type); + } /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) { + tselem->flag &= ~TSE_CHILDSEARCH; + } iterprop = RNA_struct_iterator_property(ptr->type); tot = RNA_property_collection_length(ptr, iterprop); CLAMP_MAX(tot, tot_limit); /* auto open these cases */ - if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) - if (!tselem->used) + if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) { + if (!tselem->used) { tselem->flag &= ~TSE_CLOSED; + } + } if (TSELEM_OPEN(tselem, soops)) { for (a = 0; a < tot; a++) { @@ -959,8 +1002,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi } } } - else if (tot) + else if (tot) { te->flag |= TE_LAZY_CLOSED; + } te->rnaptr = *ptr; } @@ -977,16 +1021,20 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi te->rnaptr = *ptr; /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) { + tselem->flag &= ~TSE_CHILDSEARCH; + } if (proptype == PROP_POINTER) { pptr = RNA_property_pointer_get(ptr, prop); if (pptr.data) { - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1); - else + } + else { te->flag |= TE_LAZY_CLOSED; + } } } else if (proptype == PROP_COLLECTION) { @@ -999,19 +1047,22 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a); } } - else if (tot) + else if (tot) { te->flag |= TE_LAZY_CLOSED; + } } else if (ELEM(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { tot = RNA_property_array_length(ptr, prop); CLAMP_MAX(tot, tot_limit); if (TSELEM_OPEN(tselem, soops)) { - for (a = 0; a < tot; a++) + for (a = 0; a < tot; a++) { outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a); + } } - else if (tot) + else if (tot) { te->flag |= TE_LAZY_CLOSED; + } } } else if (type == TSE_RNA_ARRAY_ELEM) { @@ -1026,8 +1077,12 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi c = RNA_property_array_item_char(prop, index); te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName"); - if (c) sprintf((char *)te->name, " %c", c); - else sprintf((char *)te->name, " %d", index + 1); + if (c) { + sprintf((char *)te->name, " %c", c); + } + else { + sprintf((char *)te->name, " %d", index + 1); + } te->flag |= TE_FREE_NAME; } } @@ -1072,8 +1127,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi } } } - else + else { te->flag |= TE_LAZY_CLOSED; + } } return te; @@ -1087,8 +1143,9 @@ static int need_add_seq_dup(Sequence *seq) { Sequence *p; - if ((!seq->strip) || (!seq->strip->stripdata)) - return(1); + if ((!seq->strip) || (!seq->strip->stripdata)) { + return 1; + } /* * First check backward, if we found a duplicate @@ -1101,8 +1158,9 @@ static int need_add_seq_dup(Sequence *seq) continue; } - if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) - return(2); + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { + return 2; + } p = p->prev; } @@ -1113,8 +1171,9 @@ static int need_add_seq_dup(Sequence *seq) continue; } - if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) - return(0); + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { + return 0; + } p = p->next; } return(1); @@ -1132,8 +1191,9 @@ static void outliner_add_seq_dup(SpaceOutliner *soops, Sequence *seq, TreeElemen continue; } - if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { /* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + } p = p->next; } } @@ -1194,9 +1254,11 @@ static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOutliner * ID *id = lbarray[a]->first; /* check if there's data in current lib */ - for (; id; id = id->next) - if (id->lib == lib) + for (; id; id = id->next) { + if (id->lib == lib) { break; + } + } if (id) { if (!tenlib) { @@ -1253,8 +1315,9 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops /* check if there are any datablocks of this type which are orphans */ for (; id; id = id->next) { - if (ID_REAL_USERS(id) <= 0) + if (ID_REAL_USERS(id) <= 0) { break; + } } if (id) { @@ -1270,8 +1333,9 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops /* 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) + if (ID_REAL_USERS(id) <= 0) { outliner_add_element(soops, (ten) ? &ten->subtree : &soops->tree, id, ten, 0, 0); + } } } } @@ -1395,7 +1459,9 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb) tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); // set correct parent pointers - for (te = tep->subtree.first; te; te = te->next) te->parent = tep; + for (te = tep->subtree.first; te; te = te->next) { + te->parent = tep; + } } } te = ten; @@ -1419,15 +1485,25 @@ static int treesort_alpha_ob(const void *v1, const void *v2) /* first put objects last (hierarchy) */ comp = (x1->idcode == ID_OB); - if (x2->idcode == ID_OB) comp += 2; + if (x2->idcode == ID_OB) { + comp += 2; + } - if (comp == 1) return 1; - else if (comp == 2) return -1; + 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; + if (comp > 0) { + return 1; + } + else if (comp < 0) { + return -1; + } return 0; } return 0; @@ -1441,8 +1517,12 @@ static int treesort_alpha(const void *v1, const void *v2) comp = strcmp(x1->name, x2->name); - if (comp > 0) return 1; - else if (comp < 0) return -1; + if (comp > 0) { + return 1; + } + else if (comp < 0) { + return -1; + } return 0; } @@ -1485,7 +1565,9 @@ static void outliner_sort(ListBase *lb) TreeStoreElem *tselem; te = lb->last; - if (te == NULL) return; + if (te == NULL) { + return; + } tselem = TREESTORE(te); /* sorting rules; only object lists, ID lists, or deformgroups */ @@ -1503,10 +1585,12 @@ static void outliner_sort(ListBase *lb) tp->name = te->name; tp->idcode = te->idcode; - if (tselem->type && tselem->type != TSE_DEFGROUP) + if (tselem->type && tselem->type != TSE_DEFGROUP) { tp->idcode = 0; // don't sort this - if (tselem->type == TSE_ID_BASE) + } + if (tselem->type == TSE_ID_BASE) { tp->idcode = 1; // do sort this + } tp->id = tselem->id; } @@ -1517,11 +1601,15 @@ static void outliner_sort(ListBase *lb) } else { /* keep beginning of list */ - for (tp = tear, skip = 0; skip < totelem; skip++, tp++) - if (tp->idcode) break; + for (tp = tear, skip = 0; skip < totelem; skip++, tp++) { + if (tp->idcode) { + break; + } + } - if (skip < totelem) + if (skip < totelem) { qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); + } } BLI_listbase_clear(lb); @@ -1567,7 +1655,9 @@ static void outliner_restore_scrolling_position(SpaceOutliner *soops, ARegion *a ys_old = focus->ys; ytop = v2d->cur.ymax + (ys_new - ys_old) -1; - if (ytop > 0) ytop = 0; + if (ytop > 0) { + ytop = 0; + } v2d->cur.ymax = (float)ytop; v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); @@ -1836,8 +1926,9 @@ static bool outliner_filter_has_name(TreeElement *te, const char *name, int flag { int fn_flag = 0; - if ((flags & SO_FIND_CASE_SENSITIVE) == 0) + if ((flags & SO_FIND_CASE_SENSITIVE) == 0) { fn_flag |= FNM_CASEFOLD; + } return fnmatch(name, te->name, fn_flag) == 0; } @@ -1932,10 +2023,12 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa /* Are we looking for something - we want to tag parents to filter child matches * - NOT in datablocks view - searching all datablocks takes way too long to be useful * - this variable is only set once per tree build */ - if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API) + if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API) { soops->search_flags |= SO_SEARCH_RECURSIVE; - else + } + else { soops->search_flags &= ~SO_SEARCH_RECURSIVE; + } if (soops->treehash && (soops->storeflag & SO_TREESTORE_REBUILD) && soops->treestore) { soops->storeflag &= ~SO_TREESTORE_REBUILD; @@ -1960,8 +2053,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa ten = outliner_add_library_contents(mainvar, soops, &soops->tree, NULL); if (ten) { tselem = TREESTORE(ten); - if (!tselem->used) + if (!tselem->used) { tselem->flag &= ~TSE_CLOSED; + } } for (lib = mainvar->libraries.first; lib; lib = lib->id.next) { @@ -1999,8 +2093,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa } } /* restore newid pointers */ - for (lib = mainvar->libraries.first; lib; lib = lib->id.next) + for (lib = mainvar->libraries.first; lib; lib = lib->id.next) { lib->id.newid = NULL; + } } else if (soops->outlinevis == SO_SCENES) { @@ -2021,12 +2116,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa Editing *ed = BKE_sequencer_editing_get(scene, false); int op; - if (ed == NULL) + if (ed == NULL) { return; + } seq = ed->seqbasep->first; - if (!seq) + if (!seq) { return; + } while (seq) { op = need_add_seq_dup(seq); diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 3afb4f4d75a..a44a6e605de 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -91,9 +91,13 @@ TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store { TreeElement *te, *tes; for (te = lb->first; te; te = te->next) { - if (te->store_elem == store_elem) return te; + if (te->store_elem == store_elem) { + return te; + } tes = outliner_find_tree_element(&te->subtree, store_elem); - if (tes) return tes; + if (tes) { + return tes; + } } return NULL; } @@ -120,12 +124,15 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse) { TreeStoreElem *tselem; - if (tse->id == NULL) return NULL; + 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; } @@ -192,7 +199,9 @@ ID *outliner_search_back(SpaceOutliner *UNUSED(soops), TreeElement *te, short id while (te) { tselem = TREESTORE(te); - if (tselem->type == 0 && te->idcode == idcode) return tselem->id; + if (tselem->type == 0 && te->idcode == idcode) { + return tselem->id; + } te = te->parent; } return NULL; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 822f9ec61ac..dc51d501b99 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -172,16 +172,19 @@ static void outliner_main_region_listener( break; case NC_LAMP: /* For updating light icons, when changing light type */ - if (wmn->data == ND_LIGHTING_DRAW) + if (wmn->data == ND_LIGHTING_DRAW) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_OUTLINER) + if (wmn->data == ND_SPACE_OUTLINER) { ED_region_tag_redraw(ar); + } break; case NC_ID: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_region_tag_redraw(ar); + } break; case NC_MATERIAL: switch (wmn->data) { @@ -205,14 +208,16 @@ static void outliner_main_region_listener( ED_region_tag_redraw(ar); break; case ND_ANIMCHAN: - if (wmn->action == NA_SELECTED) + if (wmn->action == NA_SELECTED) { ED_region_tag_redraw(ar); + } break; } break; case NC_GPENCIL: - if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) + if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } break; case NC_SCREEN: if (ELEM(wmn->data, ND_LAYER)) { @@ -276,12 +281,14 @@ static void outliner_header_region_listener( /* context changes */ switch (wmn->category) { case NC_SCENE: - if (wmn->data == ND_KEYINGSET) + if (wmn->data == ND_KEYINGSET) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_OUTLINER) + if (wmn->data == ND_SPACE_OUTLINER) { ED_region_tag_redraw(ar); + } break; } } -- cgit v1.2.3