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