diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/space_buttons/buttons_context.c | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/space_buttons/buttons_context.c')
-rw-r--r-- | source/blender/editors/space_buttons/buttons_context.c | 323 |
1 files changed, 162 insertions, 161 deletions
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 440c3c66a4b..b698ec03668 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -70,10 +70,10 @@ static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, S PointerRNA *ptr; int a; - for(a=0; a<path->len; a++) { + 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)) { CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data); return 1; } @@ -87,10 +87,10 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) PointerRNA *ptr; int a; - for(a=0; a<path->len; a++) { + 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; } @@ -116,15 +116,15 @@ static int buttons_context_path_world(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) world, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_World)) { + if (RNA_struct_is_a(ptr->type, &RNA_World)) { return 1; } /* if we have a scene, use the scene's world */ - else if(buttons_context_path_scene(path)) { + else if (buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; world= scene->world; - if(world) { + if (world) { RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); path->len++; return 1; @@ -146,15 +146,15 @@ static int buttons_context_path_object(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) object, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_Object)) { + if (RNA_struct_is_a(ptr->type, &RNA_Object)) { return 1; } /* if we have a scene, use the scene's active object */ - else if(buttons_context_path_scene(path)) { + else if (buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; ob= (scene->basact)? scene->basact->object: NULL; - if(ob) { + if (ob) { RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); path->len++; @@ -172,19 +172,19 @@ 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 || ELEM3(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_Lamp) && (type == -1 || type == OB_LAMP)) return 1; - else if(RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) 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 || ELEM3(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_Lamp) && (type == -1 || type == OB_LAMP)) return 1; + else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; /* try to get an object in the path, no pinning supported here */ - else if(buttons_context_path_object(path)) { + else if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && (type == -1 || type == ob->type)) { + if (ob && (type == -1 || type == ob->type)) { RNA_id_pointer_create(ob->data, &path->ptr[path->len]); path->len++; @@ -200,10 +200,10 @@ static int buttons_context_path_modifier(ButsContextPath *path) { Object *ob; - if(buttons_context_path_object(path)) { + if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) + if (ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) return 1; } @@ -217,23 +217,23 @@ static int buttons_context_path_material(ButsContextPath *path, int for_texture) Material *ma; /* if we already have a (pinned) material, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_Material)) { + if (RNA_struct_is_a(ptr->type, &RNA_Material)) { return 1; } /* if we have an object, use the object material slot */ - else if(buttons_context_path_object(path)) { + else if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { + if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { ma= give_current_material(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; - if(for_texture && give_current_material_texture_node(ma)) + if (for_texture && give_current_material_texture_node(ma)) return 1; ma= give_node_material(ma); - if(ma) { + if (ma) { RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; } @@ -251,11 +251,11 @@ static int buttons_context_path_bone(ButsContextPath *path) EditBone *edbo; /* if we have an armature, get the active bone */ - if(buttons_context_path_data(path, OB_ARMATURE)) { + if (buttons_context_path_data(path, OB_ARMATURE)) { arm= path->ptr[path->len-1].data; - if(arm->edbo) { - if(arm->act_edbone) { + if (arm->edbo) { + if (arm->act_edbone) { edbo= arm->act_edbone; RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]); path->len++; @@ -263,7 +263,7 @@ static int buttons_context_path_bone(ButsContextPath *path) } } else { - if(arm->act_bone) { + if (arm->act_bone) { RNA_pointer_create(&arm->id, &RNA_Bone, arm->act_bone, &path->ptr[path->len]); path->len++; return 1; @@ -280,22 +280,22 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) PoseBone, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { + if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { return 1; } /* if we have an armature, get the active bone */ - if(buttons_context_path_object(path)) { + if (buttons_context_path_object(path)) { Object *ob= path->ptr[path->len-1].data; bArmature *arm= ob->data; /* path->ptr[path->len-1].data - works too */ - if(ob->type != OB_ARMATURE || arm->edbo) { + if (ob->type != OB_ARMATURE || arm->edbo) { return 0; } else { - if(arm->act_bone) { + if (arm->act_bone) { bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name); - if(pchan) { + if (pchan) { RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]); path->len++; return 1; @@ -316,14 +316,14 @@ static int buttons_context_path_particle(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have (pinned) particle settings, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { + if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { return 1; } /* if we have an object, get the active particle system */ - if(buttons_context_path_object(path)) { + if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && ob->type == OB_MESH) { + if (ob && ob->type == OB_MESH) { psys= psys_get_current(ob); RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); @@ -343,17 +343,17 @@ static int buttons_context_path_brush(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) brush, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_Brush)) { + if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { return 1; } /* if we have a scene, use the toolsettings brushes */ - else if(buttons_context_path_scene(path)) { + else if (buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; - if(scene) + if (scene) br= paint_brush(paint_get_active(scene)); - if(br) { + if (br) { RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); path->len++; @@ -367,36 +367,36 @@ static int buttons_context_path_brush(ButsContextPath *path) static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct) { - if(ct) { + if (ct) { /* new shading system */ PointerRNA *ptr= &path->ptr[path->len-1]; ID *id; /* 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 (id) { + if (GS(id->name) == ID_BR) buttons_context_path_brush(path); - else if(GS(id->name) == ID_MA) + else if (GS(id->name) == ID_MA) buttons_context_path_material(path, 0); - else if(GS(id->name) == ID_WO) + else if (GS(id->name) == ID_WO) buttons_context_path_world(path); - else if(GS(id->name) == ID_LA) + else if (GS(id->name) == ID_LA) buttons_context_path_data(path, OB_LAMP); - 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); } - if(ct->texture) { + if (ct->texture) { RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]); path->len++; } @@ -415,14 +415,14 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur int orig_len = path->len; /* 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; } /* try brush */ - if((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) { + if ((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) { br= path->ptr[path->len-1].data; - if(br) { + if (br) { tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -431,10 +431,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try world */ - if((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { + if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { wo= path->ptr[path->len-1].data; - if(wo && GS(wo->id.name)==ID_WO) { + if (wo && GS(wo->id.name)==ID_WO) { tex= give_current_world_texture(wo); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -443,8 +443,8 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try particles */ - if((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { - if(path->ptr[path->len-1].type == &RNA_ParticleSettings) { + if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { + if (path->ptr[path->len-1].type == &RNA_ParticleSettings) { ParticleSettings *part = path->ptr[path->len-1].data; tex= give_current_particle_texture(part); @@ -455,7 +455,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur else { psys= path->ptr[path->len-1].data; - if(psys && psys->part && GS(psys->part->id.name)==ID_PA) { + if (psys && psys->part && GS(psys->part->id.name)==ID_PA) { tex= give_current_particle_texture(psys->part); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -465,10 +465,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try material */ - if(buttons_context_path_material(path, 1)) { + if (buttons_context_path_material(path, 1)) { ma= path->ptr[path->len-1].data; - if(ma) { + if (ma) { tex= give_current_material_texture(ma); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -477,10 +477,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try lamp */ - if(buttons_context_path_data(path, OB_LAMP)) { + if (buttons_context_path_data(path, OB_LAMP)) { la= path->ptr[path->len-1].data; - if(la) { + if (la) { tex= give_current_lamp_texture(la); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -490,10 +490,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try brushes again in case of no material, lamp, etc */ path->len = orig_len; - if(buttons_context_path_brush(path)) { + if (buttons_context_path_brush(path)) { br= path->ptr[path->len-1].data; - if(br) { + if (br) { tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -519,7 +519,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma path->tex_ctx = sbuts->texture_context; /* if some ID datablock is pinned, set the root pointer */ - if(sbuts->pinid) { + if (sbuts->pinid) { id= sbuts->pinid; RNA_id_pointer_create(id, &path->ptr[0]); @@ -527,7 +527,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma } /* no pinned root, use scene as root */ - if(path->len == 0) { + if (path->len == 0) { id= (ID*)CTX_data_scene(C); RNA_id_pointer_create(id, &path->ptr[0]); path->len++; @@ -565,7 +565,7 @@ 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: @@ -583,9 +583,9 @@ static int buttons_shading_context(const bContext *C, int mainb) { Object *ob= CTX_data_active_object(C); - if(ELEM3(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) + if (ELEM3(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; @@ -595,11 +595,11 @@ static int buttons_shading_new_context(const bContext *C, int flag) { Object *ob= CTX_data_active_object(C); - 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; @@ -613,22 +613,22 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) buttons_texture_context_compute(C, sbuts); - if(!sbuts->path) + if (!sbuts->path) sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); path= sbuts->path; /* for each context, see if we can compute a valid path to it, if * this is the case, we know we have to display the button */ - for(a=0; a<BCONTEXT_TOT; a++) { - if(buttons_context_path(C, path, a, pflag)) { + for (a=0; a<BCONTEXT_TOT; a++) { + if (buttons_context_path(C, path, a, pflag)) { flag |= (1<<a); /* setting icon for data context */ - if(a == BCONTEXT_DATA) { + if (a == BCONTEXT_DATA) { ptr= &path->ptr[path->len-1]; - if(ptr->type) + if (ptr->type) sbuts->dataicon= RNA_struct_ui_icon(ptr->type); else sbuts->dataicon= ICON_EMPTY_DATA; @@ -642,17 +642,17 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) sbuts->mainb= sbuts->mainbuser; /* in case something becomes invalid, change */ - if((flag & (1 << sbuts->mainb)) == 0) { - if(sbuts->flag & SB_SHADING_CONTEXT) { + if ((flag & (1 << sbuts->mainb)) == 0) { + if (sbuts->flag & SB_SHADING_CONTEXT) { /* try to keep showing shading related buttons */ sbuts->mainb= buttons_shading_new_context(C, flag); } - else if(flag & BCONTEXT_OBJECT) { + else if (flag & BCONTEXT_OBJECT) { sbuts->mainb= BCONTEXT_OBJECT; } else { - for(a=0; a<BCONTEXT_TOT; a++) { - if(flag & (1 << a)) { + for (a=0; a<BCONTEXT_TOT; a++) { + if (flag & (1 << a)) { sbuts->mainb= a; break; } @@ -662,14 +662,14 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) buttons_context_path(C, path, sbuts->mainb, pflag); - if(!(flag & (1 << sbuts->mainb))) { - if(flag & (1 << BCONTEXT_OBJECT)) + if (!(flag & (1 << sbuts->mainb))) { + if (flag & (1 << BCONTEXT_OBJECT)) sbuts->mainb= BCONTEXT_OBJECT; 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 sbuts->flag &= ~SB_SHADING_CONTEXT; @@ -691,62 +691,62 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r SpaceButs *sbuts= CTX_wm_space_buts(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)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, buttons_context_dir); return 1; } - else if(CTX_data_equals(member, "world")) { + else if (CTX_data_equals(member, "world")) { set_pointer_type(path, result, &RNA_World); return 1; } - else if(CTX_data_equals(member, "object")) { + else if (CTX_data_equals(member, "object")) { set_pointer_type(path, result, &RNA_Object); return 1; } - else if(CTX_data_equals(member, "mesh")) { + else if (CTX_data_equals(member, "mesh")) { set_pointer_type(path, result, &RNA_Mesh); return 1; } - else if(CTX_data_equals(member, "armature")) { + else if (CTX_data_equals(member, "armature")) { set_pointer_type(path, result, &RNA_Armature); return 1; } - else if(CTX_data_equals(member, "lattice")) { + else if (CTX_data_equals(member, "lattice")) { set_pointer_type(path, result, &RNA_Lattice); return 1; } - else if(CTX_data_equals(member, "curve")) { + else if (CTX_data_equals(member, "curve")) { set_pointer_type(path, result, &RNA_Curve); return 1; } - else if(CTX_data_equals(member, "meta_ball")) { + else if (CTX_data_equals(member, "meta_ball")) { set_pointer_type(path, result, &RNA_MetaBall); return 1; } - else if(CTX_data_equals(member, "lamp")) { + else if (CTX_data_equals(member, "lamp")) { set_pointer_type(path, result, &RNA_Lamp); return 1; } - else if(CTX_data_equals(member, "camera")) { + else if (CTX_data_equals(member, "camera")) { set_pointer_type(path, result, &RNA_Camera); return 1; } - else if(CTX_data_equals(member, "speaker")) { + else if (CTX_data_equals(member, "speaker")) { set_pointer_type(path, result, &RNA_Speaker); return 1; } - else if(CTX_data_equals(member, "material")) { + else if (CTX_data_equals(member, "material")) { set_pointer_type(path, result, &RNA_Material); return 1; } - else if(CTX_data_equals(member, "texture")) { + else if (CTX_data_equals(member, "texture")) { ButsContextTexture *ct= sbuts->texuser; - if(ct) { + if (ct) { /* new shading system */ CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture); } @@ -757,41 +757,41 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } - else if(CTX_data_equals(member, "material_slot")) { + else if (CTX_data_equals(member, "material_slot")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr) { + if (ptr) { Object *ob= ptr->data; - if(ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) { + 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]); } } return 1; } - else if(CTX_data_equals(member, "texture_user")) { + else if (CTX_data_equals(member, "texture_user")) { ButsContextTexture *ct= sbuts->texuser; - if(!ct) + if (!ct) return -1; /* old shading system (found but not available) */ - if(ct->user && ct->user->ptr.data) { + if (ct->user && ct->user->ptr.data) { ButsTextureUser *user= ct->user; CTX_data_pointer_set(result, user->ptr.id.data, user->ptr.type, user->ptr.data); } return 1; } - else if(CTX_data_equals(member, "texture_node")) { + else if (CTX_data_equals(member, "texture_node")) { ButsContextTexture *ct= sbuts->texuser; - if(ct) { + if (ct) { /* new shading system */ - if(ct->user && ct->user->node) + if (ct->user && ct->user->node) CTX_data_pointer_set(result, &ct->user->ntree->id, &RNA_Node, ct->user->node); return 1; @@ -800,10 +800,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r /* old shading system */ PointerRNA *ptr; - if((ptr=get_pointer_type(path, &RNA_Material))) { + if ((ptr=get_pointer_type(path, &RNA_Material))) { Material *ma= ptr->data; - if(ma) { + if (ma) { bNode *node= give_current_material_texture_node(ma); CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); } @@ -812,18 +812,18 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } - else if(CTX_data_equals(member, "texture_slot")) { + else if (CTX_data_equals(member, "texture_slot")) { ButsContextTexture *ct= sbuts->texuser; PointerRNA *ptr; - if(ct) + if (ct) return 0; /* new shading system */ - if((ptr=get_pointer_type(path, &RNA_Material))) { + if ((ptr=get_pointer_type(path, &RNA_Material))) { Material *ma= ptr->data; /* if we have a node material, get slot from material in material node */ - if(ma && ma->use_nodes && ma->nodetree) { + if (ma && ma->use_nodes && ma->nodetree) { /* if there's an active texture node in the node tree, * then that texture is in context directly, without a texture slot */ if (give_current_material_texture_node(ma)) @@ -834,84 +834,85 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); else return 0; - } else if(ma) { + } + else if (ma) { CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); } } - else if((ptr=get_pointer_type(path, &RNA_Lamp))) { + else if ((ptr=get_pointer_type(path, &RNA_Lamp))) { Lamp *la= ptr->data; - if(la) + if (la) CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]); } - else if((ptr=get_pointer_type(path, &RNA_World))) { + else if ((ptr=get_pointer_type(path, &RNA_World))) { World *wo= ptr->data; - if(wo) + if (wo) CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]); } - else if((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ + else if ((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ Brush *br= ptr->data; - if(br) + if (br) CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex); } - else if((ptr=get_pointer_type(path, &RNA_ParticleSystem))) { + else 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]); } return 1; } - else if(CTX_data_equals(member, "bone")) { + else if (CTX_data_equals(member, "bone")) { set_pointer_type(path, result, &RNA_Bone); return 1; } - else if(CTX_data_equals(member, "edit_bone")) { + else if (CTX_data_equals(member, "edit_bone")) { set_pointer_type(path, result, &RNA_EditBone); return 1; } - else if(CTX_data_equals(member, "pose_bone")) { + else if (CTX_data_equals(member, "pose_bone")) { set_pointer_type(path, result, &RNA_PoseBone); return 1; } - else if(CTX_data_equals(member, "particle_system")) { + else if (CTX_data_equals(member, "particle_system")) { set_pointer_type(path, result, &RNA_ParticleSystem); return 1; } - else if(CTX_data_equals(member, "particle_system_editable")) { - if(PE_poll((bContext*)C)) + else if (CTX_data_equals(member, "particle_system_editable")) { + if (PE_poll((bContext*)C)) set_pointer_type(path, result, &RNA_ParticleSystem); else CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); return 1; } - else if(CTX_data_equals(member, "cloth")) { + else if (CTX_data_equals(member, "cloth")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); return 1; } } - else if(CTX_data_equals(member, "soft_body")) { + else if (CTX_data_equals(member, "soft_body")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody); CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md); return 1; } } - else if(CTX_data_equals(member, "fluid")) { + else if (CTX_data_equals(member, "fluid")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim); CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md); @@ -919,34 +920,34 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r } } - else if(CTX_data_equals(member, "smoke")) { + else if (CTX_data_equals(member, "smoke")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); return 1; } } - else if(CTX_data_equals(member, "collision")) { + else if (CTX_data_equals(member, "collision")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Collision); CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md); return 1; } } - else if(CTX_data_equals(member, "brush")) { + else if (CTX_data_equals(member, "brush")) { set_pointer_type(path, result, &RNA_Brush); return 1; } - else if(CTX_data_equals(member, "dynamic_paint")) { + else if (CTX_data_equals(member, "dynamic_paint")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_DynamicPaint); CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md); @@ -966,7 +967,7 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { SpaceButs *sbuts= CTX_wm_space_buts(C); - if(sbuts->flag & SB_PIN_CONTEXT) { + if (sbuts->flag & SB_PIN_CONTEXT) { sbuts->pinid= buttons_context_id_path(C); } else @@ -986,7 +987,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) char namebuf[128], *name; int a, icon; - if(!path) + if (!path) return; row= uiLayoutRow(layout, 1); @@ -998,23 +999,23 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFunc(but, pin_cb, NULL, NULL); - for(a=0; a<path->len; a++) { + for (a=0; a<path->len; a++) { ptr= &path->ptr[a]; - if(a != 0) + if (a != 0) uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); - if(ptr->data) { + if (ptr->data) { icon= RNA_struct_ui_icon(ptr->type); name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); - if(name) { - if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) + if (name) { + if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) uiItemLDrag(row, ptr, "", icon); /* save some space */ else uiItemLDrag(row, ptr, name, icon); - if(name != namebuf) + if (name != namebuf) MEM_freeN(name); } else @@ -1047,19 +1048,19 @@ ID *buttons_context_id_path(const bContext *C) PointerRNA *ptr; int a; - if(path->len) { - for(a=path->len-1; a>=0; a--) { + if (path->len) { + for (a=path->len-1; a>=0; a--) { ptr= &path->ptr[a]; /* pin particle settings instead of system, since only settings are an idblock*/ - if(sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) { - if(ptr->type == &RNA_ParticleSystem && ptr->data) { + if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) { + if (ptr->type == &RNA_ParticleSystem && ptr->data) { ParticleSystem *psys = (ParticleSystem *)ptr->data; return &psys->part->id; } } - if(ptr->id.data) { + if (ptr->id.data) { return ptr->id.data; } } |