diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-26 13:16:47 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-26 13:16:47 +0300 |
commit | ce3b78c73a7ccc16fdccf7decedb5d1578dfdf0a (patch) | |
tree | 87f1a9c41ebe6f74806f1ae76206f1d328c85700 /source/blender/editors/space_buttons | |
parent | 5279d118c2ddee0e6fef66aaf78452c1b302dd42 (diff) |
Cleanup: style, use braces for editor/spaces
Diffstat (limited to 'source/blender/editors/space_buttons')
4 files changed, 174 insertions, 81 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 152442f8671..0579e20bb5a 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -93,8 +93,9 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) for (a = 0; a < path->len; a++) { ptr = &path->ptr[a]; - if (RNA_struct_is_a(ptr->type, type)) + if (RNA_struct_is_a(ptr->type, type)) { return ptr; + } } return NULL; @@ -221,16 +222,36 @@ static int buttons_context_path_data(ButsContextPath *path, int type) PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a data, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) return 1; + if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) { + return 1; + } /* try to get an object in the path, no pinning supported here */ else if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; @@ -254,8 +275,9 @@ static int buttons_context_path_modifier(ButsContextPath *path) if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; - if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) + if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) { return 1; + } } return 0; @@ -268,8 +290,9 @@ static int buttons_context_path_shaderfx(ButsContextPath *path) if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; - if (ob && ELEM(ob->type, OB_GPENCIL)) + if (ob && ELEM(ob->type, OB_GPENCIL)) { return 1; + } } return 0; @@ -429,27 +452,34 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path PointerRNA *ptr = &path->ptr[path->len - 1]; ID *id; - if (!ct) + if (!ct) { return 0; + } /* if we already have a (pinned) texture, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Texture)) + if (RNA_struct_is_a(ptr->type, &RNA_Texture)) { return 1; + } - if (!ct->user) + if (!ct->user) { return 0; + } id = ct->user->id; if (id) { - if (GS(id->name) == ID_BR) + if (GS(id->name) == ID_BR) { buttons_context_path_brush(C, path); - else if (GS(id->name) == ID_PA) + } + else if (GS(id->name) == ID_PA) { buttons_context_path_particle(path); - else if (GS(id->name) == ID_OB) + } + else if (GS(id->name) == ID_OB) { buttons_context_path_object(path); - else if (GS(id->name) == ID_LS) + } + else if (GS(id->name) == ID_LS) { buttons_context_path_linestyle(path, CTX_wm_window(C)); + } } if (ct->texture) { @@ -568,8 +598,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma break; case BCONTEXT_BONE: found = buttons_context_path_bone(path); - if (!found) + if (!found) { found = buttons_context_path_data(path, OB_ARMATURE); + } break; case BCONTEXT_BONE_CONSTRAINT: found = buttons_context_path_pose_bone(path); @@ -588,10 +619,12 @@ static int buttons_shading_context(const bContext *C, int mainb) ViewLayer *view_layer = WM_window_get_active_view_layer(window); Object *ob = OBACT(view_layer); - if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) + if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) { return 1; - if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) + } + if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) { return 1; + } return 0; } @@ -602,12 +635,15 @@ static int buttons_shading_new_context(const bContext *C, int flag) ViewLayer *view_layer = WM_window_get_active_view_layer(window); Object *ob = OBACT(view_layer); - if (flag & (1 << BCONTEXT_MATERIAL)) + if (flag & (1 << BCONTEXT_MATERIAL)) { return BCONTEXT_MATERIAL; - else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA))) + } + else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA))) { return BCONTEXT_DATA; - else if (flag & (1 << BCONTEXT_WORLD)) + } + else if (flag & (1 << BCONTEXT_WORLD)) { return BCONTEXT_WORLD; + } return BCONTEXT_RENDER; } @@ -618,8 +654,9 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts) PointerRNA *ptr; int a, pflag = 0, flag = 0; - if (!sbuts->path) + if (!sbuts->path) { sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); + } path = sbuts->path; @@ -639,10 +676,12 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts) ptr = &path->ptr[path->len - 1]; if (ptr->type) { - if (RNA_struct_is_a(ptr->type, &RNA_Light)) + if (RNA_struct_is_a(ptr->type, &RNA_Light)) { sbuts->dataicon = ICON_OUTLINER_DATA_LIGHT; - else + } + else { sbuts->dataicon = RNA_struct_ui_icon(ptr->type); + } } else { sbuts->dataicon = ICON_EMPTY_DATA; @@ -678,16 +717,20 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts) buttons_context_path(C, path, sbuts->mainb, pflag); if (!(flag & (1 << sbuts->mainb))) { - if (flag & (1 << BCONTEXT_OBJECT)) + if (flag & (1 << BCONTEXT_OBJECT)) { sbuts->mainb = BCONTEXT_OBJECT; - else + } + else { sbuts->mainb = BCONTEXT_SCENE; + } } - if (buttons_shading_context(C, sbuts->mainb)) + if (buttons_shading_context(C, sbuts->mainb)) { sbuts->flag |= SB_SHADING_CONTEXT; - else + } + else { sbuts->flag &= ~SB_SHADING_CONTEXT; + } sbuts->pathflag = flag; } @@ -708,17 +751,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r SpaceProperties *sbuts = CTX_wm_space_properties(C); ButsContextPath *path = sbuts ? sbuts->path : NULL; - if (!path) + if (!path) { return 0; + } /* here we handle context, getting data from precomputed path */ if (CTX_data_dir(member)) { /* in case of new shading system we skip texture_slot, complex python * UI script logic depends on checking if this is available */ - if (sbuts->texuser) + if (sbuts->texuser) { CTX_data_dir_set(result, buttons_context_dir + 1); - else + } + else { CTX_data_dir_set(result, buttons_context_dir); + } return 1; } else if (CTX_data_equals(member, "scene")) { @@ -792,7 +838,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) { /* a valid actcol isn't ensured [#27526] */ int matnr = ob->actcol - 1; - if (matnr < 0) matnr = 0; + if (matnr < 0) { + matnr = 0; + } CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]); } } @@ -802,8 +850,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if (CTX_data_equals(member, "texture_user")) { ButsContextTexture *ct = sbuts->texuser; - if (!ct) + if (!ct) { return -1; + } if (ct->user && ct->user->ptr.data) { ButsTextureUser *user = ct->user; @@ -815,8 +864,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if (CTX_data_equals(member, "texture_user_property")) { ButsContextTexture *ct = sbuts->texuser; - if (!ct) + if (!ct) { return -1; + } if (ct->user && ct->user->ptr.data) { ButsTextureUser *user = ct->user; @@ -845,8 +895,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) { ParticleSettings *part = ((ParticleSystem *)ptr->data)->part; - if (part) + if (part) { CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]); + } } else if (ct) { return 0; /* new shading system */ @@ -854,8 +905,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) { FreestyleLineStyle *ls = ptr->data; - if (ls) + if (ls) { CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]); + } } return 1; @@ -877,10 +929,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "particle_system_editable")) { - if (PE_poll((bContext *)C)) + if (PE_poll((bContext *)C)) { set_pointer_type(path, result, &RNA_ParticleSystem); - else + } + else { CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); + } return 1; } else if (CTX_data_equals(member, "particle_settings")) { @@ -993,8 +1047,9 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) if (sbuts->flag & SB_PIN_CONTEXT) { sbuts->pinid = buttons_context_id_path(C); } - else + else { sbuts->pinid = NULL; + } ED_area_tag_redraw(CTX_wm_area(C)); } @@ -1011,8 +1066,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) int a, icon; bool first = true; - if (!path) + if (!path) { return; + } row = uiLayoutRow(layout, true); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); @@ -1044,8 +1100,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (name) { uiItemLDrag(row, ptr, name, icon); - if (name != namebuf) + if (name != namebuf) { MEM_freeN(name); + } } else { uiItemL(row, "", icon); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 7cec9c09767..3ae88f9cc78 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -99,8 +99,9 @@ static int file_browse_exec(bContext *C, wmOperator *op) char *str, path[FILE_MAX]; const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) + if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) { return OPERATOR_CANCELLED; + } str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); @@ -127,7 +128,9 @@ static int file_browse_exec(bContext *C, wmOperator *op) } else { char * const lslash = (char *)BLI_last_slash(str); - if (lslash) lslash[1] = '\0'; + if (lslash) { + lslash[1] = '\0'; + } } } @@ -176,8 +179,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop, &is_undo); - if (!prop) + if (!prop) { return OPERATOR_CANCELLED; + } str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); @@ -189,8 +193,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (event->alt) { char *lslash = (char *)BLI_last_slash(str); - if (lslash) + if (lslash) { *lslash = '\0'; + } } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 067e0f57433..7c1355b6b3c 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -172,14 +172,18 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * /* get data from context */ if (pinid) { - if (GS(pinid->name) == ID_SCE) + if (GS(pinid->name) == ID_SCE) { scene = (Scene *)pinid; - else if (GS(pinid->name) == ID_OB) + } + else if (GS(pinid->name) == ID_OB) { ob = (Object *)pinid; - else if (GS(pinid->name) == ID_BR) + } + else if (GS(pinid->name) == ID_BR) { brush = (Brush *)pinid; - else if (GS(pinid->name) == ID_LS) + } + else if (GS(pinid->name) == ID_LS) { linestyle = (FreestyleLineStyle *)pinid; + } } if (!scene) { @@ -201,8 +205,9 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * /* fill users */ BLI_listbase_clear(users); - if (linestyle && !limited_mode) + if (linestyle && !limited_mode) { buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style")); + } if (ob) { ParticleSystem *psys = psys_get_current(ob); @@ -290,8 +295,9 @@ void buttons_texture_context_compute(const bContext *C, SpaceProperties *sbuts) } else { /* set one user as active based on active index */ - if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) + if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) { ct->index = 0; + } ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; @@ -335,8 +341,9 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) PointerRNA texptr; Tex *tex; - if (!ct) + if (!ct) { return; + } /* set user as active */ if (user->node) { @@ -355,13 +362,16 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) ParticleSettings *part = user->ptr.id.data; int a; - for (a = 0; a < MAX_MTEX; a++) - if (user->ptr.data == part->mtex[a]) + for (a = 0; a < MAX_MTEX; a++) { + if (user->ptr.data == part->mtex[a]) { part->texact = a; + } + } } - if (sbuts && tex) + if (sbuts && tex) { sbuts->preview = 1; + } } ct->user = user; @@ -393,13 +403,16 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS PointerRNA texptr = RNA_property_pointer_get(&user->ptr, user->prop); Tex *tex = texptr.data; - if (tex) + if (tex) { BLI_snprintf(name, UI_MAX_NAME_STR, " %s - %s", user->name, tex->id.name + 2); - else + } + else { BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + } } - else + else { BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + } but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, ""); @@ -423,8 +436,9 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) ButsTextureUser *user; char name[UI_MAX_NAME_STR]; - if (!ct) + if (!ct) { return; + } /* get current user */ user = ct->user; @@ -460,12 +474,15 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p) ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; - if (!ct) + if (!ct) { return; + } - for (user = ct->users.first; user; user = user->next) - if (user->ptr.data == data_p && user->prop == prop_p) + for (user = ct->users.first; user; user = user->next) { + if (user->ptr.data == data_p && user->prop == prop_p) { break; + } + } if (user) { /* select texture */ @@ -489,13 +506,16 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope ButsTextureUser *user; /* only show button in other tabs in properties editor */ - if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) + if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) { return; + } /* find corresponding texture user */ - for (user = ct->users.first; user; user = user->next) - if (user->ptr.data == ptr->data && user->prop == prop) + for (user = ct->users.first; user; user = user->next) { + if (user->ptr.data == ptr->data && user->prop == prop) { break; + } + } /* draw button */ if (user) { diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 609ef86b003..3bf2d632a12 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -97,8 +97,9 @@ static void buttons_free(SpaceLink *sl) { SpaceProperties *sbuts = (SpaceProperties *) sl; - if (sbuts->path) + if (sbuts->path) { MEM_freeN(sbuts->path); + } if (sbuts->texuser) { ButsContextTexture *ct = sbuts->texuser; @@ -451,8 +452,9 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) SpaceProperties *sbuts = sa->spacedata.first; /* if the area's current button set is equal to the one to redraw */ - if (sbuts->mainb == buttons) + if (sbuts->mainb == buttons) { ED_area_tag_redraw(sa); + } } /* reused! */ @@ -510,10 +512,12 @@ static void buttons_area_listener( buttons_area_redraw(sa, BCONTEXT_DATA); break; case ND_MODIFIER: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_area_tag_redraw(sa); - else + } + else { buttons_area_redraw(sa, BCONTEXT_MODIFIER); + } buttons_area_redraw(sa, BCONTEXT_PHYSICS); break; case ND_CONSTRAINT: @@ -521,8 +525,9 @@ static void buttons_area_listener( buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT); break; case ND_PARTICLE: - if (wmn->action == NA_EDITED) + if (wmn->action == NA_EDITED) { buttons_area_redraw(sa, BCONTEXT_PARTICLE); + } sbuts->preview = 1; break; case ND_DRAW: @@ -589,26 +594,30 @@ static void buttons_area_listener( } break; case NC_SPACE: - if (wmn->data == ND_SPACE_PROPERTIES) + if (wmn->data == ND_SPACE_PROPERTIES) { ED_area_tag_redraw(sa); + } break; case NC_ID: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_area_tag_redraw(sa); + } break; case NC_ANIMATION: switch (wmn->data) { case ND_KEYFRAME: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { ED_area_tag_redraw(sa); + } break; } break; case NC_GPENCIL: switch (wmn->data) { case ND_DATA: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { ED_area_tag_redraw(sa); + } break; } break; @@ -616,8 +625,9 @@ static void buttons_area_listener( if (wmn->action == NA_SELECTED) { ED_area_tag_redraw(sa); /* new active node, update texture preview */ - if (sbuts->mainb == BCONTEXT_TEXTURE) + if (sbuts->mainb == BCONTEXT_TEXTURE) { sbuts->preview = 1; + } } break; /* Listener for preview render, when doing an global undo. */ @@ -635,8 +645,9 @@ static void buttons_area_listener( #endif } - if (wmn->data == ND_KEYS) + if (wmn->data == ND_KEYS) { ED_area_tag_redraw(sa); + } } static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) |