~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_buttons/buttons_context.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: buttons_context.c 28339 2010-04-22 06:59:41Z broken $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
25
23
 * ***** END GPL LICENSE BLOCK *****
26
24
 */
27
25
 
 
26
/** \file blender/editors/space_buttons/buttons_context.c
 
27
 *  \ingroup spbuttons
 
28
 */
 
29
 
 
30
 
28
31
#include <stdlib.h>
29
32
#include <string.h>
30
33
 
31
34
#include "MEM_guardedalloc.h"
32
35
 
 
36
#include "BLI_listbase.h"
 
37
#include "BLI_utildefines.h"
 
38
 
33
39
#include "DNA_armature_types.h"
34
40
#include "DNA_lamp_types.h"
35
41
#include "DNA_material_types.h"
36
42
#include "DNA_node_types.h"
37
43
#include "DNA_scene_types.h"
38
44
#include "DNA_world_types.h"
39
 
 
40
 
#include "BLI_listbase.h"
 
45
#include "DNA_speaker_types.h"
 
46
#include "DNA_brush_types.h"
41
47
 
42
48
#include "BKE_context.h"
43
 
#include "BKE_global.h"
44
49
#include "BKE_action.h"
45
50
#include "BKE_material.h"
46
51
#include "BKE_modifier.h"
48
53
#include "BKE_particle.h"
49
54
#include "BKE_screen.h"
50
55
#include "BKE_texture.h"
51
 
#include "BKE_utildefines.h"
52
 
#include "BKE_world.h"
53
56
 
54
57
#include "RNA_access.h"
55
58
 
62
65
 
63
66
#include "buttons_intern.h"     // own include
64
67
 
65
 
typedef struct ButsContextPath {
66
 
        PointerRNA ptr[8];
67
 
        int len;
68
 
        int flag;
69
 
} ButsContextPath;
70
 
 
71
68
static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
72
69
{
73
70
        PointerRNA *ptr;
74
71
        int a;
75
72
 
76
 
        for(a=0; a<path->len; a++) {
 
73
        for (a=0; a<path->len; a++) {
77
74
                ptr= &path->ptr[a];
78
75
 
79
 
                if(RNA_struct_is_a(ptr->type, type)) {
 
76
                if (RNA_struct_is_a(ptr->type, type)) {
80
77
                        CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
81
78
                        return 1;
82
79
                }
90
87
        PointerRNA *ptr;
91
88
        int a;
92
89
 
93
 
        for(a=0; a<path->len; a++) {
 
90
        for (a=0; a<path->len; a++) {
94
91
                ptr= &path->ptr[a];
95
92
 
96
 
                if(RNA_struct_is_a(ptr->type, type))
 
93
                if (RNA_struct_is_a(ptr->type, type))
97
94
                        return ptr;
98
95
        }
99
96
 
119
116
        PointerRNA *ptr= &path->ptr[path->len-1];
120
117
 
121
118
        /* if we already have a (pinned) world, we're done */
122
 
        if(RNA_struct_is_a(ptr->type, &RNA_World)) {
 
119
        if (RNA_struct_is_a(ptr->type, &RNA_World)) {
123
120
                return 1;
124
121
        }
125
122
        /* if we have a scene, use the scene's world */
126
 
        else if(buttons_context_path_scene(path)) {
 
123
        else if (buttons_context_path_scene(path)) {
127
124
                scene= path->ptr[path->len-1].data;
128
125
                world= scene->world;
129
126
                
130
 
                if(world) {
 
127
                if (world) {
131
128
                        RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]);
132
129
                        path->len++;
133
130
                        return 1;
149
146
        PointerRNA *ptr= &path->ptr[path->len-1];
150
147
 
151
148
        /* if we already have a (pinned) object, we're done */
152
 
        if(RNA_struct_is_a(ptr->type, &RNA_Object)) {
 
149
        if (RNA_struct_is_a(ptr->type, &RNA_Object)) {
153
150
                return 1;
154
151
        }
155
152
        /* if we have a scene, use the scene's active object */
156
 
        else if(buttons_context_path_scene(path)) {
 
153
        else if (buttons_context_path_scene(path)) {
157
154
                scene= path->ptr[path->len-1].data;
158
155
                ob= (scene->basact)? scene->basact->object: NULL;
159
156
 
160
 
                if(ob) {
 
157
                if (ob) {
161
158
                        RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
162
159
                        path->len++;
163
160
 
175
172
        PointerRNA *ptr= &path->ptr[path->len-1];
176
173
 
177
174
        /* if we already have a data, we're done */
178
 
        if(RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
179
 
        else if(RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM3(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
180
 
        else if(RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
181
 
        else if(RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
182
 
        else if(RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
183
 
        else if(RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
184
 
        else if(RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
 
175
        if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
 
176
        else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM3(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
 
177
        else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
 
178
        else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
 
179
        else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
 
180
        else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
 
181
        else if (RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
 
182
        else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1;
185
183
        /* try to get an object in the path, no pinning supported here */
186
 
        else if(buttons_context_path_object(path)) {
 
184
        else if (buttons_context_path_object(path)) {
187
185
                ob= path->ptr[path->len-1].data;
188
186
 
189
 
                if(ob && (type == -1 || type == ob->type)) {
 
187
                if (ob && (type == -1 || type == ob->type)) {
190
188
                        RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
191
189
                        path->len++;
192
190
 
202
200
{
203
201
        Object *ob;
204
202
 
205
 
        if(buttons_context_path_object(path)) {
 
203
        if (buttons_context_path_object(path)) {
206
204
                ob= path->ptr[path->len-1].data;
207
205
 
208
 
                if(ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE))
 
206
                if (ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE))
209
207
                        return 1;
210
208
        }
211
209
 
212
210
        return 0;
213
211
}
214
212
 
215
 
static int buttons_context_path_material(ButsContextPath *path)
 
213
static int buttons_context_path_material(ButsContextPath *path, int for_texture)
216
214
{
217
215
        Object *ob;
218
216
        PointerRNA *ptr= &path->ptr[path->len-1];
219
217
        Material *ma;
220
218
 
221
219
        /* if we already have a (pinned) material, we're done */
222
 
        if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
 
220
        if (RNA_struct_is_a(ptr->type, &RNA_Material)) {
223
221
                return 1;
224
222
        }
225
223
        /* if we have an object, use the object material slot */
226
 
        else if(buttons_context_path_object(path)) {
 
224
        else if (buttons_context_path_object(path)) {
227
225
                ob= path->ptr[path->len-1].data;
228
226
 
229
 
                if(ob && ob->type && (ob->type<OB_LAMP)) {
 
227
                if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
230
228
                        ma= give_current_material(ob, ob->actcol);
231
229
                        RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
232
230
                        path->len++;
 
231
 
 
232
                        if (for_texture && give_current_material_texture_node(ma))
 
233
                                return 1;
 
234
                        
 
235
                        ma= give_node_material(ma);
 
236
                        if (ma) {
 
237
                                RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
 
238
                                path->len++;
 
239
                        }                       
233
240
                        return 1;
234
241
                }
235
242
        }
244
251
        EditBone *edbo;
245
252
 
246
253
        /* if we have an armature, get the active bone */
247
 
        if(buttons_context_path_data(path, OB_ARMATURE)) {
 
254
        if (buttons_context_path_data(path, OB_ARMATURE)) {
248
255
                arm= path->ptr[path->len-1].data;
249
256
 
250
 
                if(arm->edbo) {
251
 
                        if(arm->act_edbone) {
 
257
                if (arm->edbo) {
 
258
                        if (arm->act_edbone) {
252
259
                                edbo= arm->act_edbone;
253
260
                                RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]);
254
261
                                path->len++;
256
263
                        }
257
264
                }
258
265
                else {
259
 
                        if(arm->act_bone) {
 
266
                        if (arm->act_bone) {
260
267
                                RNA_pointer_create(&arm->id, &RNA_Bone, arm->act_bone, &path->ptr[path->len]);
261
268
                                path->len++;
262
269
                                return 1;
273
280
        PointerRNA *ptr= &path->ptr[path->len-1];
274
281
 
275
282
        /* if we already have a (pinned) PoseBone, we're done */
276
 
        if(RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
 
283
        if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) {
277
284
                return 1;
278
285
        }
279
286
 
280
287
        /* if we have an armature, get the active bone */
281
 
        if(buttons_context_path_object(path)) {
 
288
        if (buttons_context_path_object(path)) {
282
289
                Object *ob= path->ptr[path->len-1].data;
283
290
                bArmature *arm= ob->data; /* path->ptr[path->len-1].data - works too */
284
291
 
285
 
                if(ob->type != OB_ARMATURE || arm->edbo) {
 
292
                if (ob->type != OB_ARMATURE || arm->edbo) {
286
293
                        return 0;
287
294
                }
288
295
                else {
289
 
                        if(arm->act_bone) {
 
296
                        if (arm->act_bone) {
290
297
                                bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name);
291
 
                                if(pchan) {
 
298
                                if (pchan) {
292
299
                                        RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]);
293
300
                                        path->len++;
294
301
                                        return 1;
306
313
{
307
314
        Object *ob;
308
315
        ParticleSystem *psys;
 
316
        PointerRNA *ptr= &path->ptr[path->len-1];
309
317
 
 
318
        /* if we already have (pinned) particle settings, we're done */
 
319
        if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) {
 
320
                return 1;
 
321
        }
310
322
        /* if we have an object, get the active particle system */
311
 
        if(buttons_context_path_object(path)) {
 
323
        if (buttons_context_path_object(path)) {
312
324
                ob= path->ptr[path->len-1].data;
313
325
 
314
 
                if(ob && ob->type == OB_MESH) {
 
326
                if (ob && ob->type == OB_MESH) {
315
327
                        psys= psys_get_current(ob);
316
328
 
317
329
                        RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]);
324
336
        return 0;
325
337
}
326
338
 
327
 
static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
 
339
static int buttons_context_path_brush(ButsContextPath *path)
328
340
{
329
341
        Scene *scene;
330
342
        Brush *br= NULL;
331
343
        PointerRNA *ptr= &path->ptr[path->len-1];
332
344
 
333
345
        /* if we already have a (pinned) brush, we're done */
334
 
        if(RNA_struct_is_a(ptr->type, &RNA_Brush)) {
 
346
        if (RNA_struct_is_a(ptr->type, &RNA_Brush)) {
335
347
                return 1;
336
348
        }
337
349
        /* if we have a scene, use the toolsettings brushes */
338
 
        else if(buttons_context_path_scene(path)) {
 
350
        else if (buttons_context_path_scene(path)) {
339
351
                scene= path->ptr[path->len-1].data;
340
352
 
341
 
                if(scene)
 
353
                if (scene)
342
354
                        br= paint_brush(paint_get_active(scene));
343
355
 
344
 
                if(br) {
345
 
                        RNA_id_pointer_create(&br->id, &path->ptr[path->len]);
 
356
                if (br) {
 
357
                        RNA_id_pointer_create((ID *)br, &path->ptr[path->len]);
346
358
                        path->len++;
347
359
 
348
360
                        return 1;
353
365
        return 0;
354
366
}
355
367
 
356
 
static int buttons_context_path_texture(const bContext *C, ButsContextPath *path)
 
368
static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct)
357
369
{
358
 
        Material *ma;
359
 
        Lamp *la;
360
 
        Brush *br;
361
 
        World *wo;
362
 
        Tex *tex;
363
 
        PointerRNA *ptr= &path->ptr[path->len-1];
364
 
        int orig_len = path->len;
365
 
 
366
 
        /* if we already have a (pinned) texture, we're done */
367
 
        if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
 
370
        if (ct) {
 
371
                /* new shading system */
 
372
                PointerRNA *ptr= &path->ptr[path->len-1];
 
373
                ID *id;
 
374
 
 
375
                /* if we already have a (pinned) texture, we're done */
 
376
                if (RNA_struct_is_a(ptr->type, &RNA_Texture))
 
377
                        return 1;
 
378
 
 
379
                if (!ct->user)
 
380
                        return 0;
 
381
                
 
382
                id= ct->user->id;
 
383
 
 
384
                if (id) {
 
385
                        if (GS(id->name) == ID_BR)
 
386
                                buttons_context_path_brush(path);
 
387
                        else if (GS(id->name) == ID_MA)
 
388
                                buttons_context_path_material(path, 0);
 
389
                        else if (GS(id->name) == ID_WO)
 
390
                                buttons_context_path_world(path);
 
391
                        else if (GS(id->name) == ID_LA)
 
392
                                buttons_context_path_data(path, OB_LAMP);
 
393
                        else if (GS(id->name) == ID_PA)
 
394
                                buttons_context_path_particle(path);
 
395
                        else if (GS(id->name) == ID_OB)
 
396
                                buttons_context_path_object(path);
 
397
                }
 
398
                
 
399
                if (ct->texture) {
 
400
                        RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]);
 
401
                        path->len++;
 
402
                }
 
403
 
368
404
                return 1;
369
405
        }
370
 
        /* try brush */
371
 
        if((path->flag & SB_BRUSH_TEX) && buttons_context_path_brush(C, path)) {
372
 
                br= path->ptr[path->len-1].data;
373
 
                
374
 
                if(br) {
375
 
                        tex= give_current_brush_texture(br);
376
 
 
377
 
                        RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
378
 
                        path->len++;
379
 
                        return 1;
380
 
                }
381
 
        }
382
 
        /* try world */
383
 
        if((path->flag & SB_WORLD_TEX) && buttons_context_path_world(path)) {
384
 
                wo= path->ptr[path->len-1].data;
385
 
 
386
 
                if(wo && GS(wo->id.name)==ID_WO) {
387
 
                        tex= give_current_world_texture(wo);
388
 
 
389
 
                        RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
390
 
                        path->len++;
391
 
                        return 1;
392
 
                }
393
 
        }
394
 
        /* try material */
395
 
        if(buttons_context_path_material(path)) {
396
 
                ma= path->ptr[path->len-1].data;
397
 
 
398
 
                if(ma) {
399
 
                        tex= give_current_material_texture(ma);
400
 
 
401
 
                        RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
402
 
                        path->len++;
403
 
                        return 1;
404
 
                }
405
 
        }
406
 
        /* try lamp */
407
 
        if(buttons_context_path_data(path, OB_LAMP)) {
408
 
                la= path->ptr[path->len-1].data;
409
 
 
410
 
                if(la) {
411
 
                        tex= give_current_lamp_texture(la);
412
 
 
413
 
                        RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
414
 
                        path->len++;
415
 
                        return 1;
416
 
                }
417
 
        }
418
 
        /* try brushes again in case of no material, lamp, etc */
419
 
        path->len = orig_len;
420
 
        if(buttons_context_path_brush(C, path)) {
421
 
                br= path->ptr[path->len-1].data;
422
 
                
423
 
                if(br) {
424
 
                        tex= give_current_brush_texture(br);
425
 
                        
426
 
                        RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
427
 
                        path->len++;
428
 
                        return 1;
 
406
        else {
 
407
                /* old shading system */
 
408
                Material *ma;
 
409
                Lamp *la;
 
410
                Brush *br;
 
411
                World *wo;
 
412
                ParticleSystem *psys;
 
413
                Tex *tex;
 
414
                PointerRNA *ptr= &path->ptr[path->len-1];
 
415
                int orig_len = path->len;
 
416
 
 
417
                /* if we already have a (pinned) texture, we're done */
 
418
                if (RNA_struct_is_a(ptr->type, &RNA_Texture)) {
 
419
                        return 1;
 
420
                }
 
421
                /* try brush */
 
422
                if ((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) {
 
423
                        br= path->ptr[path->len-1].data;
 
424
                        
 
425
                        if (br) {
 
426
                                tex= give_current_brush_texture(br);
 
427
 
 
428
                                RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
429
                                path->len++;
 
430
                                return 1;
 
431
                        }
 
432
                }
 
433
                /* try world */
 
434
                if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) {
 
435
                        wo= path->ptr[path->len-1].data;
 
436
 
 
437
                        if (wo && GS(wo->id.name)==ID_WO) {
 
438
                                tex= give_current_world_texture(wo);
 
439
 
 
440
                                RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
441
                                path->len++;
 
442
                                return 1;
 
443
                        }
 
444
                }
 
445
                /* try particles */
 
446
                if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) {
 
447
                        if (path->ptr[path->len-1].type == &RNA_ParticleSettings) {
 
448
                                ParticleSettings *part = path->ptr[path->len-1].data;
 
449
 
 
450
                                tex= give_current_particle_texture(part);
 
451
                                RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
452
                                path->len++;
 
453
                                return 1;
 
454
                        }
 
455
                        else {
 
456
                                psys= path->ptr[path->len-1].data;
 
457
 
 
458
                                if (psys && psys->part && GS(psys->part->id.name)==ID_PA) {
 
459
                                        tex= give_current_particle_texture(psys->part);
 
460
 
 
461
                                        RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
462
                                        path->len++;
 
463
                                        return 1;
 
464
                                }
 
465
                        }
 
466
                }
 
467
                /* try material */
 
468
                if (buttons_context_path_material(path, 1)) {
 
469
                        ma= path->ptr[path->len-1].data;
 
470
 
 
471
                        if (ma) {
 
472
                                tex= give_current_material_texture(ma);
 
473
 
 
474
                                RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
475
                                path->len++;
 
476
                                return 1;
 
477
                        }
 
478
                }
 
479
                /* try lamp */
 
480
                if (buttons_context_path_data(path, OB_LAMP)) {
 
481
                        la= path->ptr[path->len-1].data;
 
482
 
 
483
                        if (la) {
 
484
                                tex= give_current_lamp_texture(la);
 
485
 
 
486
                                RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
487
                                path->len++;
 
488
                                return 1;
 
489
                        }
 
490
                }
 
491
                /* try brushes again in case of no material, lamp, etc */
 
492
                path->len = orig_len;
 
493
                if (buttons_context_path_brush(path)) {
 
494
                        br= path->ptr[path->len-1].data;
 
495
                        
 
496
                        if (br) {
 
497
                                tex= give_current_brush_texture(br);
 
498
                                
 
499
                                RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
 
500
                                path->len++;
 
501
                                return 1;
 
502
                        }
429
503
                }
430
504
        }
431
505
 
442
516
 
443
517
        memset(path, 0, sizeof(*path));
444
518
        path->flag= flag;
 
519
        path->tex_ctx = sbuts->texture_context;
445
520
 
446
521
        /* if some ID datablock is pinned, set the root pointer */
447
 
        if(sbuts->pinid) {
 
522
        if (sbuts->pinid) {
448
523
                id= sbuts->pinid;
449
524
 
450
525
                RNA_id_pointer_create(id, &path->ptr[0]);
452
527
        }
453
528
 
454
529
        /* no pinned root, use scene as root */
455
 
        if(path->len == 0) {
 
530
        if (path->len == 0) {
456
531
                id= (ID*)CTX_data_scene(C);
457
532
                RNA_id_pointer_create(id, &path->ptr[0]);
458
533
                path->len++;
483
558
                        found= buttons_context_path_particle(path);
484
559
                        break;
485
560
                case BCONTEXT_MATERIAL:
486
 
                        found= buttons_context_path_material(path);
 
561
                        found= buttons_context_path_material(path, 0);
487
562
                        break;
488
563
                case BCONTEXT_TEXTURE:
489
 
                        found= buttons_context_path_texture(C, path);
 
564
                        found= buttons_context_path_texture(path, sbuts->texuser);
490
565
                        break;
491
566
                case BCONTEXT_BONE:
492
567
                        found= buttons_context_path_bone(path);
493
 
                        if(!found)
 
568
                        if (!found)
494
569
                                found= buttons_context_path_data(path, OB_ARMATURE);
495
570
                        break;
496
571
                case BCONTEXT_BONE_CONSTRAINT:
508
583
{
509
584
        Object *ob= CTX_data_active_object(C);
510
585
 
511
 
        if(ELEM3(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE))
 
586
        if (ELEM3(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE))
512
587
                return 1;
513
 
        if(mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA))
 
588
        if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA))
514
589
                return 1;
515
590
        
516
591
        return 0;
517
592
}
518
593
 
519
 
static int buttons_shading_new_context(const bContext *C, int flag, int mainb)
 
594
static int buttons_shading_new_context(const bContext *C, int flag)
520
595
{
521
596
        Object *ob= CTX_data_active_object(C);
522
597
 
523
 
        if(flag & (1 << BCONTEXT_MATERIAL))
 
598
        if (flag & (1 << BCONTEXT_MATERIAL))
524
599
                return BCONTEXT_MATERIAL;
525
 
        else if(ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA)))
 
600
        else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA)))
526
601
                return BCONTEXT_DATA;
527
 
        else if(flag & (1 << BCONTEXT_WORLD))
 
602
        else if (flag & (1 << BCONTEXT_WORLD))
528
603
                return BCONTEXT_WORLD;
529
604
        
530
605
        return BCONTEXT_RENDER;
534
609
{
535
610
        ButsContextPath *path;
536
611
        PointerRNA *ptr;
537
 
        int a, pflag, flag= 0;
538
 
 
539
 
        if(!sbuts->path)
 
612
        int a, pflag= 0, flag= 0;
 
613
 
 
614
        buttons_texture_context_compute(C, sbuts);
 
615
 
 
616
        if (!sbuts->path)
540
617
                sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
541
618
        
542
619
        path= sbuts->path;
543
 
        pflag= (sbuts->flag & (SB_WORLD_TEX|SB_BRUSH_TEX));
544
620
        
545
621
        /* for each context, see if we can compute a valid path to it, if
546
622
         * this is the case, we know we have to display the button */
547
 
        for(a=0; a<BCONTEXT_TOT; a++) {
548
 
                if(buttons_context_path(C, path, a, pflag)) {
 
623
        for (a=0; a<BCONTEXT_TOT; a++) {
 
624
                if (buttons_context_path(C, path, a, pflag)) {
549
625
                        flag |= (1<<a);
550
626
 
551
627
                        /* setting icon for data context */
552
 
                        if(a == BCONTEXT_DATA) {
 
628
                        if (a == BCONTEXT_DATA) {
553
629
                                ptr= &path->ptr[path->len-1];
554
630
 
555
 
                                if(ptr->type)
 
631
                                if (ptr->type)
556
632
                                        sbuts->dataicon= RNA_struct_ui_icon(ptr->type);
557
633
                                else
558
634
                                        sbuts->dataicon= ICON_EMPTY_DATA;
566
642
        sbuts->mainb= sbuts->mainbuser;
567
643
 
568
644
        /* in case something becomes invalid, change */
569
 
        if((flag & (1 << sbuts->mainb)) == 0) {
570
 
                if(sbuts->flag & SB_SHADING_CONTEXT) {
 
645
        if ((flag & (1 << sbuts->mainb)) == 0) {
 
646
                if (sbuts->flag & SB_SHADING_CONTEXT) {
571
647
                        /* try to keep showing shading related buttons */
572
 
                        sbuts->mainb= buttons_shading_new_context(C, flag, sbuts->mainb);
 
648
                        sbuts->mainb= buttons_shading_new_context(C, flag);
573
649
                }
574
 
                else if(flag & BCONTEXT_OBJECT) {
 
650
                else if (flag & BCONTEXT_OBJECT) {
575
651
                        sbuts->mainb= BCONTEXT_OBJECT;
576
652
                }
577
653
                else {
578
 
                        for(a=0; a<BCONTEXT_TOT; a++) {
579
 
                                if(flag & (1 << a)) {
 
654
                        for (a=0; a<BCONTEXT_TOT; a++) {
 
655
                                if (flag & (1 << a)) {
580
656
                                        sbuts->mainb= a;
581
657
                                        break;
582
658
                                }
586
662
 
587
663
        buttons_context_path(C, path, sbuts->mainb, pflag);
588
664
 
589
 
        if(!(flag & (1 << sbuts->mainb))) {
590
 
                if(flag & (1 << BCONTEXT_OBJECT))
 
665
        if (!(flag & (1 << sbuts->mainb))) {
 
666
                if (flag & (1 << BCONTEXT_OBJECT))
591
667
                        sbuts->mainb= BCONTEXT_OBJECT;
592
668
                else
593
669
                        sbuts->mainb= BCONTEXT_SCENE;
594
670
        }
595
671
 
596
 
        if(buttons_shading_context(C, sbuts->mainb))
 
672
        if (buttons_shading_context(C, sbuts->mainb))
597
673
                sbuts->flag |= SB_SHADING_CONTEXT;
598
674
        else
599
675
                sbuts->flag &= ~SB_SHADING_CONTEXT;
603
679
 
604
680
/************************* Context Callback ************************/
605
681
 
 
682
const char *buttons_context_dir[] = {
 
683
        "world", "object", "mesh", "armature", "lattice", "curve",
 
684
        "meta_ball", "lamp", "speaker", "camera", "material", "material_slot",
 
685
        "texture", "texture_slot", "texture_user", "bone", "edit_bone",
 
686
        "pose_bone", "particle_system", "particle_system_editable",
 
687
        "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL};
 
688
 
606
689
int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
607
690
{
608
691
        SpaceButs *sbuts= CTX_wm_space_buts(C);
609
692
        ButsContextPath *path= sbuts?sbuts->path:NULL;
610
693
 
611
 
        if(!path)
 
694
        if (!path)
612
695
                return 0;
613
696
 
614
697
        /* here we handle context, getting data from precomputed path */
615
 
        if(CTX_data_dir(member)) {
616
 
                static const char *dir[] = {
617
 
                        "world", "object", "mesh", "armature", "lattice", "curve",
618
 
                        "meta_ball", "lamp", "camera", "material", "material_slot",
619
 
                        "texture", "texture_slot", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable",
620
 
                        "cloth", "soft_body", "fluid", "smoke", "collision", "brush", NULL};
621
 
 
622
 
                CTX_data_dir_set(result, dir);
 
698
        if (CTX_data_dir(member)) {
 
699
                CTX_data_dir_set(result, buttons_context_dir);
623
700
                return 1;
624
701
        }
625
 
        else if(CTX_data_equals(member, "world")) {
 
702
        else if (CTX_data_equals(member, "world")) {
626
703
                set_pointer_type(path, result, &RNA_World);
627
704
                return 1;
628
705
        }
629
 
        else if(CTX_data_equals(member, "object")) {
 
706
        else if (CTX_data_equals(member, "object")) {
630
707
                set_pointer_type(path, result, &RNA_Object);
631
708
                return 1;
632
709
        }
633
 
        else if(CTX_data_equals(member, "mesh")) {
 
710
        else if (CTX_data_equals(member, "mesh")) {
634
711
                set_pointer_type(path, result, &RNA_Mesh);
635
712
                return 1;
636
713
        }
637
 
        else if(CTX_data_equals(member, "armature")) {
 
714
        else if (CTX_data_equals(member, "armature")) {
638
715
                set_pointer_type(path, result, &RNA_Armature);
639
716
                return 1;
640
717
        }
641
 
        else if(CTX_data_equals(member, "lattice")) {
 
718
        else if (CTX_data_equals(member, "lattice")) {
642
719
                set_pointer_type(path, result, &RNA_Lattice);
643
720
                return 1;
644
721
        }
645
 
        else if(CTX_data_equals(member, "curve")) {
 
722
        else if (CTX_data_equals(member, "curve")) {
646
723
                set_pointer_type(path, result, &RNA_Curve);
647
724
                return 1;
648
725
        }
649
 
        else if(CTX_data_equals(member, "meta_ball")) {
 
726
        else if (CTX_data_equals(member, "meta_ball")) {
650
727
                set_pointer_type(path, result, &RNA_MetaBall);
651
728
                return 1;
652
729
        }
653
 
        else if(CTX_data_equals(member, "lamp")) {
 
730
        else if (CTX_data_equals(member, "lamp")) {
654
731
                set_pointer_type(path, result, &RNA_Lamp);
655
732
                return 1;
656
733
        }
657
 
        else if(CTX_data_equals(member, "camera")) {
 
734
        else if (CTX_data_equals(member, "camera")) {
658
735
                set_pointer_type(path, result, &RNA_Camera);
659
736
                return 1;
660
737
        }
661
 
        else if(CTX_data_equals(member, "material")) {
 
738
        else if (CTX_data_equals(member, "speaker")) {
 
739
                set_pointer_type(path, result, &RNA_Speaker);
 
740
                return 1;
 
741
        }
 
742
        else if (CTX_data_equals(member, "material")) {
662
743
                set_pointer_type(path, result, &RNA_Material);
663
744
                return 1;
664
745
        }
665
 
        else if(CTX_data_equals(member, "texture")) {
666
 
                set_pointer_type(path, result, &RNA_Texture);
 
746
        else if (CTX_data_equals(member, "texture")) {
 
747
                ButsContextTexture *ct= sbuts->texuser;
 
748
 
 
749
                if (ct) {
 
750
                        /* new shading system */
 
751
                        CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture);
 
752
                }
 
753
                else {
 
754
                        /* old shading system */
 
755
                        set_pointer_type(path, result, &RNA_Texture);
 
756
                }
 
757
 
667
758
                return 1;
668
759
        }
669
 
        else if(CTX_data_equals(member, "material_slot")) {
 
760
        else if (CTX_data_equals(member, "material_slot")) {
670
761
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
671
762
 
672
 
                if(ptr) {
 
763
                if (ptr) {
673
764
                        Object *ob= ptr->data;
674
765
 
675
 
                        if(ob && ob->type && (ob->type<OB_LAMP) && ob->totcol)
676
 
                                CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1);
677
 
                }
678
 
 
679
 
                return 1;
680
 
        }
681
 
        else if(CTX_data_equals(member, "texture_node")) {
682
 
                PointerRNA *ptr;
683
 
 
684
 
                if((ptr=get_pointer_type(path, &RNA_Material))) {
685
 
                        Material *ma= ptr->data;
686
 
 
687
 
                        if(ma) {
688
 
                                bNode *node= give_current_material_texture_node(ma);
689
 
                                CTX_data_pointer_set(result, &ma->id, &RNA_Node, node);
690
 
                        }
691
 
                }
692
 
 
693
 
                return 1;
694
 
        }
695
 
        else if(CTX_data_equals(member, "texture_slot")) {
696
 
                PointerRNA *ptr;
697
 
 
698
 
                if((ptr=get_pointer_type(path, &RNA_Material))) {
 
766
                        if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) {
 
767
                                /* a valid actcol isn't ensured [#27526] */
 
768
                                int matnr= ob->actcol-1;
 
769
                                if (matnr < 0) matnr= 0;
 
770
                                CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]);
 
771
                        }
 
772
                }
 
773
 
 
774
                return 1;
 
775
        }
 
776
        else if (CTX_data_equals(member, "texture_user")) {
 
777
                ButsContextTexture *ct= sbuts->texuser;
 
778
 
 
779
                if (!ct)
 
780
                        return -1; /* old shading system (found but not available) */
 
781
 
 
782
                if (ct->user && ct->user->ptr.data) {
 
783
                        ButsTextureUser *user= ct->user; 
 
784
                        CTX_data_pointer_set(result, user->ptr.id.data, user->ptr.type, user->ptr.data);
 
785
                }
 
786
 
 
787
                return 1;
 
788
        }
 
789
        else if (CTX_data_equals(member, "texture_node")) {
 
790
                ButsContextTexture *ct= sbuts->texuser;
 
791
 
 
792
                if (ct) {
 
793
                        /* new shading system */
 
794
                        if (ct->user && ct->user->node)
 
795
                                CTX_data_pointer_set(result, &ct->user->ntree->id, &RNA_Node, ct->user->node);
 
796
 
 
797
                        return 1;
 
798
                }
 
799
                else {
 
800
                        /* old shading system */
 
801
                        PointerRNA *ptr;
 
802
 
 
803
                        if ((ptr=get_pointer_type(path, &RNA_Material))) {
 
804
                                Material *ma= ptr->data;
 
805
 
 
806
                                if (ma) {
 
807
                                        bNode *node= give_current_material_texture_node(ma);
 
808
                                        CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node);
 
809
                                }
 
810
                        }
 
811
 
 
812
                        return 1;
 
813
                }
 
814
        }
 
815
        else if (CTX_data_equals(member, "texture_slot")) {
 
816
                ButsContextTexture *ct= sbuts->texuser;
 
817
                PointerRNA *ptr;
 
818
 
 
819
                if (ct)
 
820
                        return 0; /* new shading system */
 
821
 
 
822
                if ((ptr=get_pointer_type(path, &RNA_Material))) {
699
823
                        Material *ma= ptr->data;
700
824
 
701
825
                        /* if we have a node material, get slot from material in material node */
702
 
                        if(ma && ma->use_nodes && ma->nodetree) {
 
826
                        if (ma && ma->use_nodes && ma->nodetree) {
703
827
                                /* if there's an active texture node in the node tree,
704
828
                                 * then that texture is in context directly, without a texture slot */
705
829
                                if (give_current_material_texture_node(ma))
710
834
                                        CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
711
835
                                else
712
836
                                        return 0;
713
 
                        } else if(ma) {
 
837
                        }
 
838
                        else if (ma) {
714
839
                                CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
715
840
                        }
716
841
                }
717
 
                else if((ptr=get_pointer_type(path, &RNA_Lamp))) {
 
842
                else if ((ptr=get_pointer_type(path, &RNA_Lamp))) {
718
843
                        Lamp *la= ptr->data;
719
844
 
720
 
                        if(la)
 
845
                        if (la)
721
846
                                CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]);
722
847
                }
723
 
                else if((ptr=get_pointer_type(path, &RNA_World))) {
 
848
                else if ((ptr=get_pointer_type(path, &RNA_World))) {
724
849
                        World *wo= ptr->data;
725
850
 
726
 
                        if(wo)
 
851
                        if (wo)
727
852
                                CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
728
853
                }
729
 
                else if((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */
 
854
                else if ((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */
730
855
                        Brush *br= ptr->data;
731
856
 
732
 
                        if(br)
 
857
                        if (br)
733
858
                                CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex);
734
859
                }
 
860
                else if ((ptr=get_pointer_type(path, &RNA_ParticleSystem))) {
 
861
                        ParticleSettings *part= ((ParticleSystem *)ptr->data)->part;
 
862
 
 
863
                        if (part)
 
864
                                CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]);
 
865
                }
735
866
 
736
867
                return 1;
737
868
        }
738
 
        else if(CTX_data_equals(member, "bone")) {
 
869
        else if (CTX_data_equals(member, "bone")) {
739
870
                set_pointer_type(path, result, &RNA_Bone);
740
871
                return 1;
741
872
        }
742
 
        else if(CTX_data_equals(member, "edit_bone")) {
 
873
        else if (CTX_data_equals(member, "edit_bone")) {
743
874
                set_pointer_type(path, result, &RNA_EditBone);
744
875
                return 1;
745
876
        }
746
 
        else if(CTX_data_equals(member, "pose_bone")) {
 
877
        else if (CTX_data_equals(member, "pose_bone")) {
747
878
                set_pointer_type(path, result, &RNA_PoseBone);
748
879
                return 1;
749
880
        }
750
 
        else if(CTX_data_equals(member, "particle_system")) {
 
881
        else if (CTX_data_equals(member, "particle_system")) {
751
882
                set_pointer_type(path, result, &RNA_ParticleSystem);
752
883
                return 1;
753
884
        }
754
 
        else if(CTX_data_equals(member, "particle_system_editable")) {
755
 
                if(PE_poll((bContext*)C))
 
885
        else if (CTX_data_equals(member, "particle_system_editable")) {
 
886
                if (PE_poll((bContext*)C))
756
887
                        set_pointer_type(path, result, &RNA_ParticleSystem);
757
888
                else
758
889
                        CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL);
759
890
                return 1;
760
891
        }       
761
 
        else if(CTX_data_equals(member, "cloth")) {
 
892
        else if (CTX_data_equals(member, "cloth")) {
762
893
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
763
894
 
764
 
                if(ptr && ptr->data) {
 
895
                if (ptr && ptr->data) {
765
896
                        Object *ob= ptr->data;
766
897
                        ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth);
767
898
                        CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md);
768
899
                        return 1;
769
900
                }
770
901
        }
771
 
        else if(CTX_data_equals(member, "soft_body")) {
 
902
        else if (CTX_data_equals(member, "soft_body")) {
772
903
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
773
904
 
774
 
                if(ptr && ptr->data) {
 
905
                if (ptr && ptr->data) {
775
906
                        Object *ob= ptr->data;
776
907
                        ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody);
777
908
                        CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md);
778
909
                        return 1;
779
910
                }
780
911
        }
781
 
        else if(CTX_data_equals(member, "fluid")) {
 
912
        else if (CTX_data_equals(member, "fluid")) {
782
913
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
783
914
 
784
 
                if(ptr && ptr->data) {
 
915
                if (ptr && ptr->data) {
785
916
                        Object *ob= ptr->data;
786
917
                        ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim);
787
918
                        CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md);
789
920
                }
790
921
        }
791
922
        
792
 
        else if(CTX_data_equals(member, "smoke")) {
 
923
        else if (CTX_data_equals(member, "smoke")) {
793
924
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
794
925
 
795
 
                if(ptr && ptr->data) {
 
926
                if (ptr && ptr->data) {
796
927
                        Object *ob= ptr->data;
797
928
                        ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke);
798
929
                        CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md);
799
930
                        return 1;
800
931
                }
801
932
        }
802
 
        else if(CTX_data_equals(member, "collision")) {
 
933
        else if (CTX_data_equals(member, "collision")) {
803
934
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
804
935
 
805
 
                if(ptr && ptr->data) {
 
936
                if (ptr && ptr->data) {
806
937
                        Object *ob= ptr->data;
807
938
                        ModifierData *md= modifiers_findByType(ob, eModifierType_Collision);
808
939
                        CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md);
809
940
                        return 1;
810
941
                }
811
942
        }
812
 
        else if(CTX_data_equals(member, "brush")) {
 
943
        else if (CTX_data_equals(member, "brush")) {
813
944
                set_pointer_type(path, result, &RNA_Brush);
814
945
                return 1;
815
946
        }
 
947
        else if (CTX_data_equals(member, "dynamic_paint")) {
 
948
                PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
 
949
 
 
950
                if (ptr && ptr->data) {
 
951
                        Object *ob= ptr->data;
 
952
                        ModifierData *md= modifiers_findByType(ob, eModifierType_DynamicPaint);
 
953
                        CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md);
 
954
                        return 1;
 
955
                }
 
956
        }
816
957
        else {
817
958
                return 0; /* not found */
818
959
        }
822
963
 
823
964
/************************* Drawing the Path ************************/
824
965
 
825
 
static void pin_cb(bContext *C, void *arg1, void *arg2)
 
966
static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
826
967
{
827
968
        SpaceButs *sbuts= CTX_wm_space_buts(C);
828
969
 
829
 
        if(sbuts->flag & SB_PIN_CONTEXT) {
 
970
        if (sbuts->flag & SB_PIN_CONTEXT) {
830
971
                sbuts->pinid= buttons_context_id_path(C);
831
972
        }
832
973
        else
846
987
        char namebuf[128], *name;
847
988
        int a, icon;
848
989
 
849
 
        if(!path)
 
990
        if (!path)
850
991
                return;
851
992
 
852
993
        row= uiLayoutRow(layout, 1);
854
995
 
855
996
        block= uiLayoutGetBlock(row);
856
997
        uiBlockSetEmboss(block, UI_EMBOSSN);
857
 
        but= uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed");
 
998
        but = uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed");
 
999
        uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
858
1000
        uiButSetFunc(but, pin_cb, NULL, NULL);
859
1001
 
860
 
        for(a=0; a<path->len; a++) {
 
1002
        for (a=0; a<path->len; a++) {
861
1003
                ptr= &path->ptr[a];
862
1004
 
863
 
                if(a != 0)
 
1005
                if (a != 0)
864
1006
                        uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC);
865
1007
 
866
 
                if(ptr->data) {
 
1008
                if (ptr->data) {
867
1009
                        icon= RNA_struct_ui_icon(ptr->type);
868
 
                        name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf));
 
1010
                        name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL);
869
1011
 
870
 
                        if(name) {
871
 
                                if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene)
 
1012
                        if (name) {
 
1013
                                if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene)
872
1014
                                        uiItemLDrag(row, ptr, "", icon); /* save some space */
873
1015
                                else
874
1016
                                        uiItemLDrag(row, ptr, name, icon);
875
1017
                                                                 
876
 
                                if(name != namebuf)
 
1018
                                if (name != namebuf)
877
1019
                                        MEM_freeN(name);
878
1020
                        }
879
1021
                        else
906
1048
        PointerRNA *ptr;
907
1049
        int a;
908
1050
 
909
 
        if(path->len) {
910
 
                for(a=path->len-1; a>=0; a--) {
 
1051
        if (path->len) {
 
1052
                for (a=path->len-1; a>=0; a--) {
911
1053
                        ptr= &path->ptr[a];
912
1054
 
913
 
                        if(ptr->id.data) {
 
1055
                        /* pin particle settings instead of system, since only settings are an idblock*/
 
1056
                        if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) {
 
1057
                                if (ptr->type == &RNA_ParticleSystem && ptr->data) {
 
1058
                                        ParticleSystem *psys = (ParticleSystem *)ptr->data;
 
1059
                                        return &psys->part->id;
 
1060
                                }
 
1061
                        }
 
1062
 
 
1063
                        if (ptr->id.data) {
914
1064
                                return ptr->id.data;
915
 
                                break;
916
1065
                        }
917
1066
                }
918
1067
        }