fix [#28967] Attempting to add a new pose to the Pose Library causes Blender 2.60...
[blender.git] / source / blender / editors / space_view3d / view3d_header.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2004-2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file blender/editors/space_view3d/view3d_header.c
30  *  \ingroup spview3d
31  */
32
33
34 #include <string.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 #include "DNA_scene_types.h"
39 #include "DNA_object_types.h"
40
41 #include "RNA_access.h"
42
43 #include "MEM_guardedalloc.h"
44
45 #include "BLI_math.h"
46 #include "BLI_blenlib.h"
47 #include "BLI_editVert.h"
48 #include "BLI_utildefines.h"
49
50 #include "BLF_translation.h"
51
52 #include "BKE_context.h"
53 #include "BKE_depsgraph.h"
54 #include "BKE_effect.h"
55 #include "BKE_main.h"
56 #include "BKE_mesh.h"
57 #include "BKE_modifier.h"
58 #include "BKE_paint.h"
59 #include "BKE_screen.h"
60
61 #include "ED_mesh.h"
62 #include "ED_util.h"
63 #include "ED_screen.h"
64 #include "ED_transform.h"
65 #include "ED_types.h"
66
67 #include "WM_api.h"
68 #include "WM_types.h"
69
70 #include "RNA_define.h"
71 #include "RNA_enum_types.h"
72
73 #include "UI_interface.h"
74 #include "UI_resources.h"
75
76 #include "view3d_intern.h"
77
78
79 /* View3d->modeselect 
80  * This is a bit of a dodgy hack to enable a 'mode' menu with icons+labels
81  * rather than those buttons.
82  * I know the implementation's not good - it's an experiment to see if this
83  * approach would work well
84  *
85  * This can be cleaned when I make some new 'mode' icons.
86  */
87
88 #define TEST_EDITMESH   if(obedit==0) return; \
89                                                 if( (v3d->lay & obedit->lay)==0 ) return;
90
91 /* view3d handler codes */
92 #define VIEW3D_HANDLER_BACKGROUND       1
93 #define VIEW3D_HANDLER_PROPERTIES       2
94 #define VIEW3D_HANDLER_OBJECT           3
95 #define VIEW3D_HANDLER_PREVIEW          4
96 #define VIEW3D_HANDLER_MULTIRES         5
97 #define VIEW3D_HANDLER_TRANSFORM        6
98 #define VIEW3D_HANDLER_GREASEPENCIL 7
99 #define VIEW3D_HANDLER_BONESKETCH       8
100
101 /* end XXX ************* */
102
103 static void do_view3d_header_buttons(bContext *C, void *arg, int event);
104
105 #define B_SCENELOCK 101
106 #define B_FULL          102
107 #define B_HOME          103
108 #define B_VIEWBUT       104
109 #define B_PERSP         105
110 #define B_MODESELECT 108
111 #define B_SEL_VERT      110
112 #define B_SEL_EDGE      111
113 #define B_SEL_FACE      112
114 #define B_MAN_TRANS     116
115 #define B_MAN_ROT       117
116 #define B_MAN_SCALE     118
117 #define B_NDOF          119     
118 #define B_MAN_MODE      120
119 #define B_REDR          122
120 #define B_NOP           123
121
122 // XXX quickly ported across
123 static void handle_view3d_lock(bContext *C) 
124 {
125         Main *bmain= CTX_data_main(C);
126         Scene *scene= CTX_data_scene(C);
127         ScrArea *sa= CTX_wm_area(C);
128         View3D *v3d= CTX_wm_view3d(C);
129         
130         if (v3d != NULL && sa != NULL) {
131                 if(v3d->localvd==NULL && v3d->scenelock && sa->spacetype==SPACE_VIEW3D) {
132                         /* copy to scene */
133                         scene->lay= v3d->lay;
134                         scene->layact= v3d->layact;
135                         scene->camera= v3d->camera;
136
137                         /* not through notifiery, listener don't have context
138                            and non-open screens or spaces need to be updated too */
139                         BKE_screen_view3d_main_sync(&bmain->screen, scene);
140                         
141                         /* notifiers for scene update */
142                         WM_event_add_notifier(C, NC_SCENE|ND_LAYER, scene);
143                 }
144         }
145 }
146
147 /* layer code is on three levels actually:
148 - here for operator
149 - uiTemplateLayers in interface/ code for buttons
150 - ED_view3d_scene_layer_set for RNA
151  */
152 static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d)
153 {
154         /* sanity check - when in editmode disallow switching the editmode layer off since its confusing
155          * an alternative would be to always draw the editmode object. */
156         if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) {
157                 int bit;
158                 for(bit=0; bit<32; bit++) {
159                         if(scene->obedit->lay & (1<<bit)) {
160                                 v3d->lay |= 1<<bit;
161                                 break;
162                         }
163                 }
164         }
165 }
166
167 static int view3d_layers_exec(bContext *C, wmOperator *op)
168 {
169         Scene *scene= CTX_data_scene(C);
170         ScrArea *sa= CTX_wm_area(C);
171         View3D *v3d= sa->spacedata.first;
172         int nr= RNA_int_get(op->ptr, "nr");
173         int toggle= RNA_boolean_get(op->ptr, "toggle");
174         
175         if(nr < 0)
176                 return OPERATOR_CANCELLED;
177
178         if(nr == 0) {
179                 /* all layers */
180                 if(!v3d->layact)
181                         v3d->layact= 1;
182
183                 if (toggle && v3d->lay == ((1<<20)-1)) {
184                         /* return to active layer only */
185                         v3d->lay = v3d->layact;
186
187                         view3d_layers_editmode_ensure(scene, v3d);
188                 }
189                 else {
190                         v3d->lay |= (1<<20)-1;
191                 }               
192         }
193         else {
194                 int bit;
195                 nr--;
196
197                 if(RNA_boolean_get(op->ptr, "extend")) {
198                         if(toggle && v3d->lay & (1<<nr) && (v3d->lay & ~(1<<nr)))
199                                 v3d->lay &= ~(1<<nr);
200                         else
201                                 v3d->lay |= (1<<nr);
202                 } else {
203                         v3d->lay = (1<<nr);
204                 }
205
206                 view3d_layers_editmode_ensure(scene, v3d);
207
208                 /* set active layer, ensure to always have one */
209                 if(v3d->lay & (1<<nr))
210                    v3d->layact= 1<<nr;
211                 else if((v3d->lay & v3d->layact)==0) {
212                         for(bit=0; bit<32; bit++) {
213                                 if(v3d->lay & (1<<bit)) {
214                                         v3d->layact= 1<<bit;
215                                         break;
216                                 }
217                         }
218                 }
219         }
220         
221         if(v3d->scenelock) handle_view3d_lock(C);
222         
223         DAG_on_visible_update(CTX_data_main(C), FALSE);
224
225         ED_area_tag_redraw(sa);
226         
227         return OPERATOR_FINISHED;
228 }
229
230 /* applies shift and alt, lazy coding or ok? :) */
231 /* the local per-keymap-entry keymap will solve it */
232 static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event)
233 {
234         if(event->ctrl || event->oskey)
235                 return OPERATOR_PASS_THROUGH;
236         
237         if(event->shift)
238                 RNA_boolean_set(op->ptr, "extend", 1);
239         
240         if(event->alt) {
241                 int nr= RNA_int_get(op->ptr, "nr") + 10;
242                 RNA_int_set(op->ptr, "nr", nr);
243         }
244         view3d_layers_exec(C, op);
245         
246         return OPERATOR_FINISHED;
247 }
248
249 static int view3d_layers_poll(bContext *C)
250 {
251         return (ED_operator_view3d_active(C) && CTX_wm_view3d(C)->localvd==NULL);
252 }
253
254 void VIEW3D_OT_layers(wmOperatorType *ot)
255 {
256         /* identifiers */
257         ot->name= "Layers";
258         ot->description= "Toggle layer(s) visibility";
259         ot->idname= "VIEW3D_OT_layers";
260         
261         /* api callbacks */
262         ot->invoke= view3d_layers_invoke;
263         ot->exec= view3d_layers_exec;
264         ot->poll= view3d_layers_poll;
265         
266         /* flags */
267         ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
268         
269         RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20);
270         RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers");
271         RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
272 }
273
274 static int modeselect_addmode(char *str, const char *title, int id, int icon)
275 {
276         static char formatstr[] = "|%s %%x%d %%i%d";
277
278         return sprintf(str, formatstr, IFACE_(title), id, icon);
279 }
280
281 static char *view3d_modeselect_pup(Scene *scene)
282 {
283         Object *ob= OBACT;
284         static char string[256];
285         const char *title= IFACE_("Mode: %t");
286         char *str = string;
287
288         BLI_strncpy(str, title, sizeof(string));
289
290         str += modeselect_addmode(str, N_("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA);
291         
292         if(ob==NULL || ob->data==NULL) return string;
293         if(ob->id.lib) return string;
294         
295         if(!((ID *)ob->data)->lib) {
296                 /* if active object is editable */
297                 if ( ((ob->type == OB_MESH)
298                         || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
299                         || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
300                         
301                         str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
302                 }
303                 else if (ob->type == OB_ARMATURE) {
304                         if (ob->mode & OB_MODE_POSE)
305                                 str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
306                         else
307                                 str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
308                 }
309
310                 if (ob->type == OB_MESH) {
311
312                         str += modeselect_addmode(str, N_("Sculpt Mode"), OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
313                         str += modeselect_addmode(str, N_("Vertex Paint"), OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
314                         str += modeselect_addmode(str, N_("Texture Paint"), OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
315                         str += modeselect_addmode(str, N_("Weight Paint"), OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
316                 }
317         }
318                 
319         /* if active object is an armature */
320         if (ob->type==OB_ARMATURE) {
321                 str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT);
322         }
323
324         if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) {
325                 str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
326         }
327         (void)str;
328         return (string);
329 }
330
331
332 static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
333 {
334         wmWindow *win= CTX_wm_window(C);
335         ToolSettings *ts= CTX_data_tool_settings(C);
336         ScrArea *sa= CTX_wm_area(C);
337         View3D *v3d= sa->spacedata.first;
338         Object *obedit = CTX_data_edit_object(C);
339         EditMesh *em= NULL;
340         int ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
341         PointerRNA props_ptr;
342         
343         if(obedit && obedit->type==OB_MESH) {
344                 em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
345         }
346         /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
347
348         switch(event) {
349         case B_REDR:
350                 ED_area_tag_redraw(sa);
351                 break;
352                 
353         case B_MODESELECT:
354                 WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
355                 RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
356                 WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr);
357                 WM_operator_properties_free(&props_ptr);
358                 break;          
359                 
360         case B_SEL_VERT:
361                 if(em) {
362                         if(shift==0 || em->selectmode==0)
363                                 em->selectmode= SCE_SELECT_VERTEX;
364                         ts->selectmode= em->selectmode;
365                         EM_selectmode_set(em);
366                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
367                         ED_undo_push(C, "Selectmode Set: Vertex");
368                 }
369                 break;
370         case B_SEL_EDGE:
371                 if(em) {
372                         if(shift==0 || em->selectmode==0){
373                                 if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){
374                                         if(ctrl) EM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); 
375                                 }
376                                 em->selectmode = SCE_SELECT_EDGE;
377                         }
378                         ts->selectmode= em->selectmode;
379                         EM_selectmode_set(em);
380                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
381                         ED_undo_push(C, "Selectmode Set: Edge");
382                 }
383                 break;
384         case B_SEL_FACE:
385                 if(em) {
386                         if( shift==0 || em->selectmode==0){
387                                 if( ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
388                                         if(ctrl)
389                                                 EM_convertsel(em, (em->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
390                                 }
391                                 em->selectmode = SCE_SELECT_FACE;
392                         }
393                         ts->selectmode= em->selectmode;
394                         EM_selectmode_set(em);
395                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
396                         ED_undo_push(C, "Selectmode Set: Face");
397                 }
398                 break;  
399
400         case B_MAN_TRANS:
401                 if( shift==0 || v3d->twtype==0) {
402                         v3d->twtype= V3D_MANIP_TRANSLATE;
403                 }
404                 ED_area_tag_redraw(sa);
405                 break;
406         case B_MAN_ROT:
407                 if( shift==0 || v3d->twtype==0) {
408                         v3d->twtype= V3D_MANIP_ROTATE;
409                 }
410                 ED_area_tag_redraw(sa);
411                 break;
412         case B_MAN_SCALE:
413                 if( shift==0 || v3d->twtype==0) {
414                         v3d->twtype= V3D_MANIP_SCALE;
415                 }
416                 ED_area_tag_redraw(sa);
417                 break;
418         case B_NDOF:
419                 ED_area_tag_redraw(sa);
420                 break;
421         case B_MAN_MODE:
422                 ED_area_tag_redraw(sa);
423                 break;
424         default:
425                 break;
426         }
427
428         if(obedit && obedit->type==OB_MESH)
429                 BKE_mesh_end_editmesh(obedit->data, em);
430 }
431
432 /* Returns the icon associated with an object mode */
433 static int object_mode_icon(int mode)
434 {
435         EnumPropertyItem *item = object_mode_items;
436         
437         while(item->name != NULL) {
438                 if(item->value == mode)
439                         return item->icon;
440                 ++item;
441         }
442
443         return ICON_OBJECT_DATAMODE;
444 }
445
446 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
447 {
448         Object *obedit = CTX_data_edit_object(C);
449         uiBlock *block= uiLayoutGetBlock(layout);
450
451         uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
452
453         if(obedit && (obedit->type == OB_MESH)) {
454                 EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
455                 uiLayout *row;
456
457                 row= uiLayoutRow(layout, 1);
458                 block= uiLayoutGetBlock(row);
459                 uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode");
460                 uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode");
461                 uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, 0,0,UI_UNIT_X,UI_UNIT_Y, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode");
462
463                 BKE_mesh_end_editmesh(obedit->data, em);
464         }
465 }
466
467 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
468 {
469         bScreen *screen= CTX_wm_screen(C);
470         ScrArea *sa= CTX_wm_area(C);
471         View3D *v3d= sa->spacedata.first;
472         Scene *scene= CTX_data_scene(C);
473         ToolSettings *ts= CTX_data_tool_settings(C);
474         PointerRNA v3dptr, toolsptr, sceneptr;
475         Object *ob= OBACT;
476         Object *obedit = CTX_data_edit_object(C);
477         uiBlock *block;
478         uiBut *but;
479         uiLayout *row;
480         const float dpi_fac= UI_DPI_FAC;
481         
482         RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);        
483         RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
484         RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
485
486         block= uiLayoutGetBlock(layout);
487         uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
488
489         /* other buttons: */
490         uiBlockSetEmboss(block, UI_EMBOSS);
491         
492         /* mode */
493         if(ob)
494                 v3d->modeselect = ob->mode;
495         else
496                 v3d->modeselect = OB_MODE_OBJECT;
497
498         uiBlockBeginAlign(block);
499         uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , 
500                           0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode"));
501         uiBlockEndAlign(block);
502         
503         /* Draw type */
504         uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
505
506         if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) {
507                 /* Manipulators aren't used in weight paint mode */
508                 
509                 PointerRNA meshptr;
510
511                 RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
512                 if(ob->mode & (OB_MODE_TEXTURE_PAINT|OB_MODE_VERTEX_PAINT)) {
513                         uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
514                 }
515                 else {
516                         
517                         row= uiLayoutRow(layout, 1);
518                         uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
519                         uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
520                 }
521         } else {
522                 const char *str_menu;
523
524                 row= uiLayoutRow(layout, 1);
525                 uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
526
527                 /* pose/object only however we want to allow in weight paint mode too
528                  * so dont be totally strict and just check not-editmode for now */
529                 if (obedit == NULL) {
530                         uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
531                 }
532
533                 /* Transform widget / manipulators */
534                 row= uiLayoutRow(layout, 1);
535                 uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
536                 block= uiLayoutGetBlock(row);
537                 
538                 if(v3d->twflag & V3D_USE_MANIPULATOR) {
539                         but= uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Translate manipulator mode"));
540                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
541                         but= uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Rotate manipulator mode"));
542                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
543                         but= uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_("Scale manipulator mode"));
544                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
545                 }
546                         
547                 if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
548                         v3d->twmode = 0;
549                 }
550                         
551                 str_menu = BIF_menustringTransformOrientation(C, "Orientation");
552                 but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, TIP_("Transform Orientation"));
553                 uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
554                 MEM_freeN((void *)str_menu);
555         }
556
557         if(obedit==NULL && v3d->localvd==NULL) {
558                 unsigned int ob_lay = ob ? ob->lay : 0;
559                 
560                 /* Layers */
561                 if (v3d->scenelock)
562                         uiTemplateLayers(layout, &sceneptr, "layers", &v3dptr, "layers_used", ob_lay);
563                 else
564                         uiTemplateLayers(layout, &v3dptr, "layers", &v3dptr, "layers_used", ob_lay);
565
566                 /* Scene lock */
567                 uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
568         }
569         
570         uiTemplateEditModeSelection(layout, C);
571 }