svn merge -r 21041:21243 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender.git] / source / blender / editors / space_buttons / buttons_context.c
1 /**
2  * $Id:
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * The Original Code is Copyright (C) 2009 Blender Foundation.
21  * All rights reserved.
22  *
23  * Contributor(s): Blender Foundation
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 #include <stdlib.h>
29 #include <string.h>
30
31 #include "MEM_guardedalloc.h"
32
33 #include "DNA_armature_types.h"
34 #include "DNA_lamp_types.h"
35 #include "DNA_material_types.h"
36 #include "DNA_modifier_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_scene_types.h"
39 #include "DNA_screen_types.h"
40 #include "DNA_space_types.h"
41 #include "DNA_particle_types.h"
42 #include "DNA_texture_types.h"
43 #include "DNA_world_types.h"
44
45 #include "BLI_listbase.h"
46
47 #include "BKE_context.h"
48 #include "BKE_material.h"
49 #include "BKE_modifier.h"
50 #include "BKE_particle.h"
51 #include "BKE_screen.h"
52 #include "BKE_utildefines.h"
53 #include "BKE_world.h"
54
55 #include "RNA_access.h"
56
57 #include "ED_armature.h"
58 #include "ED_screen.h"
59
60 #include "UI_interface.h"
61 #include "UI_resources.h"
62
63 #include "buttons_intern.h"     // own include
64
65 typedef struct ButsContextPath {
66         PointerRNA ptr[8];
67         int len;
68         int worldtex;
69 } ButsContextPath;
70
71 static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type)
72 {
73         PointerRNA *ptr;
74         int a;
75
76         for(a=0; a<path->len; a++) {
77                 ptr= &path->ptr[a];
78
79                 if(RNA_struct_is_a(ptr->type, type)) {
80                         CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data);
81                         return 1;
82                 }
83         }
84
85         return 0;
86 }
87
88 static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type)
89 {
90         PointerRNA *ptr;
91         int a;
92
93         for(a=0; a<path->len; a++) {
94                 ptr= &path->ptr[a];
95
96                 if(RNA_struct_is_a(ptr->type, type))
97                         return ptr;
98         }
99
100         return NULL;
101 }
102
103 /************************* Creating the Path ************************/
104
105 static int buttons_context_path_scene(ButsContextPath *path)
106 {
107         PointerRNA *ptr= &path->ptr[path->len-1];
108
109         /* this one just verifies */
110         return RNA_struct_is_a(ptr->type, &RNA_Scene);
111 }
112
113 static int buttons_context_path_world(ButsContextPath *path)
114 {
115         Scene *scene;
116         PointerRNA *ptr= &path->ptr[path->len-1];
117
118         /* if we already have a (pinned) world, we're done */
119         if(RNA_struct_is_a(ptr->type, &RNA_World)) {
120                 return 1;
121         }
122         /* if we have a scene, use the scene's world */
123         else if(buttons_context_path_scene(path)) {
124                 scene= path->ptr[path->len-1].data;
125
126                 RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]);
127                 path->len++;
128
129                 return 1;
130         }
131
132         /* no path to a world possible */
133         return 0;
134 }
135
136
137 static int buttons_context_path_object(ButsContextPath *path)
138 {
139         Scene *scene;
140         Object *ob;
141         PointerRNA *ptr= &path->ptr[path->len-1];
142
143         /* if we already have a (pinned) object, we're done */
144         if(RNA_struct_is_a(ptr->type, &RNA_Object)) {
145                 return 1;
146         }
147         /* if we have a scene, use the scene's active object */
148         else if(buttons_context_path_scene(path)) {
149                 scene= path->ptr[path->len-1].data;
150                 ob= (scene->basact)? scene->basact->object: NULL;
151
152                 if(ob) {
153                         RNA_id_pointer_create(&ob->id, &path->ptr[path->len]);
154                         path->len++;
155
156                         return 1;
157                 }
158         }
159
160         /* no path to a object possible */
161         return 0;
162 }
163
164 static int buttons_context_path_data(ButsContextPath *path, int type)
165 {
166         Object *ob;
167         PointerRNA *ptr= &path->ptr[path->len-1];
168
169         /* if we already have a data, we're done */
170         if(RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1;
171         else if(RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM3(type, OB_CURVE, OB_SURF, OB_FONT))) return 1;
172         else if(RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
173         else if(RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
174         else if(RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
175         else if(RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
176         else if(RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
177         /* try to get an object in the path, no pinning supported here */
178         else if(buttons_context_path_object(path)) {
179                 ob= path->ptr[path->len-1].data;
180
181                 if(ob && (type == -1 || type == ob->type)) {
182                         RNA_id_pointer_create(ob->data, &path->ptr[path->len]);
183                         path->len++;
184
185                         return 1;
186                 }
187         }
188
189         /* no path to data possible */
190         return 0;
191 }
192
193 static int buttons_context_path_modifier(ButsContextPath *path)
194 {
195         Object *ob;
196
197         if(buttons_context_path_object(path)) {
198                 ob= path->ptr[path->len-1].data;
199
200                 if(ob && ELEM4(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF))
201                         return 1;
202         }
203
204         return 0;
205 }
206
207 static int buttons_context_path_material(ButsContextPath *path)
208 {
209         Object *ob;
210         PointerRNA *ptr= &path->ptr[path->len-1];
211         Material *ma;
212
213         /* if we already have a (pinned) material, we're done */
214         if(RNA_struct_is_a(ptr->type, &RNA_Material)) {
215                 return 1;
216         }
217         /* if we have an object, use the object material slot */
218         else if(buttons_context_path_object(path)) {
219                 ob= path->ptr[path->len-1].data;
220
221                 if(ob && ob->type && (ob->type<OB_LAMP)) {
222                         ma= give_current_material(ob, ob->actcol);
223                         RNA_id_pointer_create(&ma->id, &path->ptr[path->len]);
224                         path->len++;
225                         return 1;
226                 }
227         }
228
229         /* no path to a material possible */
230         return 0;
231 }
232
233 static Bone *find_active_bone(Bone *bone)
234 {
235         Bone *active;
236
237         for(; bone; bone=bone->next) {
238                 if(bone->flag & BONE_ACTIVE)
239                         return bone;
240
241                 active= find_active_bone(bone->childbase.first);
242                 if(active)
243                         return active;
244         }
245
246         return NULL;
247 }
248
249 static int buttons_context_path_bone(ButsContextPath *path)
250 {
251         bArmature *arm;
252         Bone *bone;
253         EditBone *edbo;
254
255         /* if we have an armature, get the active bone */
256         if(buttons_context_path_data(path, OB_ARMATURE)) {
257                 arm= path->ptr[path->len-1].data;
258
259                 if(arm->edbo) {
260                         for(edbo=arm->edbo->first; edbo; edbo=edbo->next) {
261                                 if(edbo->flag & BONE_ACTIVE) {
262                                         RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]);
263                                         path->len++;
264                                         return 1;
265                                 }
266                         }
267                 }
268                 else {
269                         bone= find_active_bone(arm->bonebase.first);
270
271                         if(bone) {
272                                 RNA_pointer_create(&arm->id, &RNA_Bone, bone, &path->ptr[path->len]);
273                                 path->len++;
274                                 return 1;
275                         }
276                 }
277         }
278
279         /* no path to a bone possible */
280         return 0;
281 }
282
283 static int buttons_context_path_particle(ButsContextPath *path)
284 {
285         Object *ob;
286         ParticleSystem *psys;
287
288         /* if we have an object, get the active particle system */
289         if(buttons_context_path_object(path)) {
290                 ob= path->ptr[path->len-1].data;
291
292                 if(ob && ob->type == OB_MESH) {
293                         psys= psys_get_current(ob);
294
295                         RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]);
296                         path->len++;
297                         return 1;
298                 }
299         }
300
301         /* no path to a particle system possible */
302         return 0;
303 }
304
305 static int buttons_context_path_texture(ButsContextPath *path)
306 {
307         Material *ma;
308         Lamp *la;
309         World *wo;
310         MTex *mtex;
311         Tex *tex;
312         PointerRNA *ptr= &path->ptr[path->len-1];
313
314         /* if we already have a (pinned) texture, we're done */
315         if(RNA_struct_is_a(ptr->type, &RNA_Texture)) {
316                 return 1;
317         }
318         /* try world */
319         else if(path->worldtex && buttons_context_path_world(path)) {
320                 wo= path->ptr[path->len-1].data;
321
322                 if(wo) {
323                         mtex= wo->mtex[(int)wo->texact];
324                         tex= (mtex)? mtex->tex: NULL;
325
326                         RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
327                         path->len++;
328                         return 1;
329                 }
330         }
331         /* try material */
332         else if(buttons_context_path_material(path)) {
333                 ma= path->ptr[path->len-1].data;
334
335                 if(ma) {
336                         mtex= ma->mtex[(int)ma->texact];
337                         tex= (mtex)? mtex->tex: NULL;
338
339                         RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
340                         path->len++;
341                         return 1;
342                 }
343         }
344         /* try lamp */
345         else if(buttons_context_path_data(path, OB_LAMP)) {
346                 la= path->ptr[path->len-1].data;
347
348                 if(la) {
349                         mtex= la->mtex[(int)la->texact];
350                         tex= (mtex)? mtex->tex: NULL;
351
352                         RNA_id_pointer_create(&tex->id, &path->ptr[path->len]);
353                         path->len++;
354                         return 1;
355                 }
356         }
357         /* TODO: material nodes, brush */
358
359         /* no path to a particle system possible */
360         return 0;
361 }
362
363 static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int worldtex)
364 {
365         SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
366         ID *id;
367         int found;
368
369         memset(path, 0, sizeof(*path));
370         path->worldtex= worldtex;
371
372         /* if some ID datablock is pinned, set the root pointer */
373         if(sbuts->pinid) {
374                 id= sbuts->pinid;
375
376                 RNA_id_pointer_create(id, &path->ptr[0]);
377                 path->len++;
378         }
379
380         /* no pinned root, use scene as root */
381         if(path->len == 0) {
382                 id= (ID*)CTX_data_scene(C);
383                 RNA_id_pointer_create(id, &path->ptr[0]);
384                 path->len++;
385         }
386
387         /* now for each buttons context type, we try to construct a path,
388          * tracing back recursively */
389         switch(mainb) {
390                 case BCONTEXT_SCENE:
391                         found= buttons_context_path_scene(path);
392                         break;
393                 case BCONTEXT_WORLD:
394                         found= buttons_context_path_world(path);
395                         break;
396                 case BCONTEXT_OBJECT:
397                 case BCONTEXT_PHYSICS:
398                 case BCONTEXT_CONSTRAINT:
399                         found= buttons_context_path_object(path);
400                         break;
401                 case BCONTEXT_MODIFIER:
402                         found= buttons_context_path_modifier(path);
403                         break;
404                 case BCONTEXT_DATA:
405                         found= buttons_context_path_data(path, -1);
406                         break;
407                 case BCONTEXT_PARTICLE:
408                         found= buttons_context_path_particle(path);
409                         break;
410                 case BCONTEXT_MATERIAL:
411                         found= buttons_context_path_material(path);
412                         break;
413                 case BCONTEXT_TEXTURE:
414                         found= buttons_context_path_texture(path);
415                         break;
416                 case BCONTEXT_BONE:
417                         found= buttons_context_path_bone(path);
418                         break;
419                 default:
420                         found= 0;
421                         break;
422         }
423
424         return found;
425 }
426
427 void buttons_context_compute(const bContext *C, SpaceButs *sbuts)
428 {
429         ButsContextPath *path;
430         PointerRNA *ptr;
431         int a, worldtex, flag= 0;
432
433         if(!sbuts->path)
434                 sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath");
435         
436         path= sbuts->path;
437         worldtex= (sbuts->flag & SB_WORLD_TEX);
438         
439         /* for each context, see if we can compute a valid path to it, if
440          * this is the case, we know we have to display the button */
441         for(a=0; a<BCONTEXT_TOT; a++) {
442                 if(buttons_context_path(C, path, a, worldtex)) {
443                         flag |= (1<<a);
444
445                         /* setting icon for data context */
446                         if(a == BCONTEXT_DATA) {
447                                 ptr= &path->ptr[path->len-1];
448
449                                 if(ptr->type)
450                                         sbuts->dataicon= RNA_struct_ui_icon(ptr->type);
451                                 else
452                                         sbuts->dataicon= ICON_EMPTY_DATA;
453                         }
454                 }
455         }
456
457         /* in case something becomes invalid, change */
458         if((flag & (1 << sbuts->mainb)) == 0) {
459                 if(flag & BCONTEXT_OBJECT) {
460                         sbuts->mainb= BCONTEXT_OBJECT;
461                 }
462                 else {
463                         for(a=0; a<BCONTEXT_TOT; a++) {
464                                 if(flag & (1 << a)) {
465                                         sbuts->mainb= a;
466                                         break;
467                                 }
468                         }
469                 }
470         }
471
472         buttons_context_path(C, path, sbuts->mainb, worldtex);
473
474         if(!(flag & (1 << sbuts->mainb))) {
475                 if(flag & (1 << BCONTEXT_OBJECT))
476                         sbuts->mainb= BCONTEXT_OBJECT;
477                 else
478                         sbuts->mainb= BCONTEXT_SCENE;
479         }
480
481         sbuts->pathflag= flag;
482 }
483
484 /************************* Context Callback ************************/
485
486 int buttons_context(const bContext *C, const char *member, bContextDataResult *result)
487 {
488         SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
489         ButsContextPath *path= sbuts?sbuts->path:NULL;
490
491         if(!path)
492                 return 0;
493
494         /* here we handle context, getting data from precomputed path */
495         if(CTX_data_dir(member)) {
496                 static const char *dir[] = {
497                         "world", "object", "meshe", "armature", "lattice", "curve",
498                         "meta_ball", "lamp", "camera", "material", "material_slot",
499                         "texture", "texture_slot", "bone", "edit_bone", "particle_system",
500                         "cloth", "soft_body", "fluid", NULL};
501
502                 CTX_data_dir_set(result, dir);
503                 return 1;
504         }
505         else if(CTX_data_equals(member, "world")) {
506                 set_pointer_type(path, result, &RNA_World);
507                 return 1;
508         }
509         else if(CTX_data_equals(member, "object")) {
510                 set_pointer_type(path, result, &RNA_Object);
511                 return 1;
512         }
513         else if(CTX_data_equals(member, "mesh")) {
514                 set_pointer_type(path, result, &RNA_Mesh);
515                 return 1;
516         }
517         else if(CTX_data_equals(member, "armature")) {
518                 set_pointer_type(path, result, &RNA_Armature);
519                 return 1;
520         }
521         else if(CTX_data_equals(member, "lattice")) {
522                 set_pointer_type(path, result, &RNA_Lattice);
523                 return 1;
524         }
525         else if(CTX_data_equals(member, "curve")) {
526                 set_pointer_type(path, result, &RNA_Curve);
527                 return 1;
528         }
529         else if(CTX_data_equals(member, "meta_ball")) {
530                 set_pointer_type(path, result, &RNA_MetaBall);
531                 return 1;
532         }
533         else if(CTX_data_equals(member, "lamp")) {
534                 set_pointer_type(path, result, &RNA_Lamp);
535                 return 1;
536         }
537         else if(CTX_data_equals(member, "camera")) {
538                 set_pointer_type(path, result, &RNA_Camera);
539                 return 1;
540         }
541         else if(CTX_data_equals(member, "material")) {
542                 set_pointer_type(path, result, &RNA_Material);
543                 return 1;
544         }
545         else if(CTX_data_equals(member, "texture")) {
546                 set_pointer_type(path, result, &RNA_Texture);
547                 return 1;
548         }
549         else if(CTX_data_equals(member, "material_slot")) {
550                 PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
551
552                 if(ptr) {
553                         Object *ob= ptr->data;
554
555                         if(ob && ob->type && (ob->type<OB_LAMP) && ob->totcol)
556                                 CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, ob->mat+ob->actcol-1);
557                 }
558
559                 return 1;
560         }
561         else if(CTX_data_equals(member, "texture_slot")) {
562                 PointerRNA *ptr;
563
564                 if((ptr=get_pointer_type(path, &RNA_Material))) {
565                         Material *ma= ptr->data;
566
567                         if(ma)
568                                 CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]);
569                 }
570                 else if((ptr=get_pointer_type(path, &RNA_Lamp))) {
571                         Lamp *la= ptr->data;
572
573                         if(la)
574                                 CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]);
575                 }
576                 else if((ptr=get_pointer_type(path, &RNA_World))) {
577                         World *wo= ptr->data;
578
579                         if(wo)
580                                 CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]);
581                 }
582                 else if((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */
583                         Brush *br= ptr->data;
584
585                         if(br)
586                                 CTX_data_pointer_set(result, &br->id, &RNA_TextureSlot, br->mtex[(int)br->texact]);
587                 }
588
589                 return 1;
590         }
591         else if(CTX_data_equals(member, "bone")) {
592                 set_pointer_type(path, result, &RNA_Bone);
593                 return 1;
594         }
595         else if(CTX_data_equals(member, "edit_bone")) {
596                 set_pointer_type(path, result, &RNA_EditBone);
597                 return 1;
598         }
599         else if(CTX_data_equals(member, "particle_system")) {
600                 set_pointer_type(path, result, &RNA_ParticleSystem);
601                 return 1;
602         }
603         else if(CTX_data_equals(member, "cloth")) {
604                 PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
605
606                 if(ptr && ptr->data) {
607                         Object *ob= ptr->data;
608                         ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth);
609                         CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md);
610                         return 1;
611                 }
612         }
613         else if(CTX_data_equals(member, "soft_body")) {
614                 PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
615
616                 if(ptr && ptr->data) {
617                         Object *ob= ptr->data;
618                         CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodySettings, ob->soft);
619                         return 1;
620                 }
621         }
622         else if(CTX_data_equals(member, "fluid")) {
623                 PointerRNA *ptr= get_pointer_type(path, &RNA_Object);
624
625                 if(ptr && ptr->data) {
626                         Object *ob= ptr->data;
627                         ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim);
628                         CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md);
629                         return 1;
630                 }
631         }
632
633         return 0;
634 }
635
636 /************************* Drawing the Path ************************/
637
638 static void pin_cb(bContext *C, void *arg1, void *arg2)
639 {
640         SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
641         ButsContextPath *path= sbuts->path;
642         PointerRNA *ptr;
643         int a;
644
645         if(sbuts->flag & SB_PIN_CONTEXT) {
646                 if(path->len) {
647                         for(a=path->len-1; a>=0; a--) {
648                                 ptr= &path->ptr[a];
649
650                                 if(ptr->id.data) {
651                                         sbuts->pinid= ptr->id.data;
652                                         break;
653                                 }
654                         }
655                 }
656         }
657         else
658                 sbuts->pinid= NULL;
659         
660         ED_area_tag_redraw(CTX_wm_area(C));
661 }
662
663 void buttons_context_draw(const bContext *C, uiLayout *layout)
664 {
665         SpaceButs *sbuts= (SpaceButs*)CTX_wm_space_data(C);
666         ButsContextPath *path= sbuts->path;
667         uiLayout *row;
668         uiBlock *block;
669         uiBut *but;
670         PointerRNA *ptr;
671         char namebuf[128], *name;
672         int a, icon;
673
674         if(!path)
675                 return;
676
677         row= uiLayoutRow(layout, 0);
678         uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
679
680         block= uiLayoutGetBlock(row);
681         uiBlockSetEmboss(block, UI_EMBOSSN);
682         but= uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, (sbuts->flag & SB_PIN_CONTEXT)? ICON_PINNED: ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed.");
683         uiButSetFunc(but, pin_cb, NULL, NULL);
684
685         for(a=0; a<path->len; a++) {
686                 ptr= &path->ptr[a];
687
688                 if(ptr->data) {
689                         icon= RNA_struct_ui_icon(ptr->type);
690                         name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf));
691
692 #if 0
693                         if(sbuts->mainb != BCONTEXT_SCENE && ptr->type == &RNA_Scene) {
694                                 uiItemL(row, "", icon); /* save some space */
695                         }
696                         else
697 #endif
698                         if(name) {
699                                 uiItemL(row, name, icon);
700
701                                 if(name != namebuf)
702                                         MEM_freeN(name);
703                         }
704                         else
705                                 uiItemL(row, "", icon);
706                 }
707         }
708 }
709
710 static void buttons_panel_context(const bContext *C, Panel *pa)
711 {
712         buttons_context_draw(C, pa->layout);
713 }
714
715 void buttons_context_register(ARegionType *art)
716 {
717         PanelType *pt;
718
719         pt= MEM_callocN(sizeof(PanelType), "spacetype buttons panel context");
720         strcpy(pt->idname, "BUTTONS_PT_context");
721         strcpy(pt->label, "Context");
722         pt->draw= buttons_panel_context;
723         BLI_addtail(&art->paneltypes, pt);
724 }
725