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