remove redundant code & use GL_LINE_STRIP for object spiral drawing.
[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         if(UI_translate_iface())
279                 return sprintf(str, formatstr, BLF_gettext(title), id, icon);
280         else
281                 return sprintf(str, formatstr, title, id, icon);
282 }
283
284 static char *view3d_modeselect_pup(Scene *scene)
285 {
286         Object *ob= OBACT;
287         static char string[256];
288         const char *title= N_("Mode: %t");
289         char *str = string;
290
291         if(U.transopts&USER_TR_IFACE)
292                 title= BLF_gettext(title);
293
294         BLI_strncpy(str, title, sizeof(string));
295
296         str += modeselect_addmode(str, N_("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA);
297         
298         if(ob==NULL || ob->data==NULL) return string;
299         if(ob->id.lib) return string;
300         
301         if(!((ID *)ob->data)->lib) {
302                 /* if active object is editable */
303                 if ( ((ob->type == OB_MESH)
304                         || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
305                         || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
306                         
307                         str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
308                 }
309                 else if (ob->type == OB_ARMATURE) {
310                         if (ob->mode & OB_MODE_POSE)
311                                 str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
312                         else
313                                 str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
314                 }
315
316                 if (ob->type == OB_MESH) {
317
318                         str += modeselect_addmode(str, N_("Sculpt Mode"), OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
319                         str += modeselect_addmode(str, N_("Vertex Paint"), OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
320                         str += modeselect_addmode(str, N_("Texture Paint"), OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
321                         str += modeselect_addmode(str, N_("Weight Paint"), OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
322                 }
323         }
324                 
325         /* if active object is an armature */
326         if (ob->type==OB_ARMATURE) {
327                 str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT);
328         }
329
330         if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) {
331                 str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
332         }
333         (void)str;
334         return (string);
335 }
336
337
338 static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
339 {
340         wmWindow *win= CTX_wm_window(C);
341         ToolSettings *ts= CTX_data_tool_settings(C);
342         ScrArea *sa= CTX_wm_area(C);
343         View3D *v3d= sa->spacedata.first;
344         Object *obedit = CTX_data_edit_object(C);
345         EditMesh *em= NULL;
346         int ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
347         PointerRNA props_ptr;
348         
349         if(obedit && obedit->type==OB_MESH) {
350                 em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
351         }
352         /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
353
354         switch(event) {
355         case B_REDR:
356                 ED_area_tag_redraw(sa);
357                 break;
358                 
359         case B_MODESELECT:
360                 WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
361                 RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
362                 WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr);
363                 WM_operator_properties_free(&props_ptr);
364                 break;          
365                 
366         case B_SEL_VERT:
367                 if(em) {
368                         if(shift==0 || em->selectmode==0)
369                                 em->selectmode= SCE_SELECT_VERTEX;
370                         ts->selectmode= em->selectmode;
371                         EM_selectmode_set(em);
372                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
373                         ED_undo_push(C, "Selectmode Set: Vertex");
374                 }
375                 break;
376         case B_SEL_EDGE:
377                 if(em) {
378                         if(shift==0 || em->selectmode==0){
379                                 if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){
380                                         if(ctrl) EM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); 
381                                 }
382                                 em->selectmode = SCE_SELECT_EDGE;
383                         }
384                         ts->selectmode= em->selectmode;
385                         EM_selectmode_set(em);
386                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
387                         ED_undo_push(C, "Selectmode Set: Edge");
388                 }
389                 break;
390         case B_SEL_FACE:
391                 if(em) {
392                         if( shift==0 || em->selectmode==0){
393                                 if( ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((em->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
394                                         if(ctrl)
395                                                 EM_convertsel(em, (em->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
396                                 }
397                                 em->selectmode = SCE_SELECT_FACE;
398                         }
399                         ts->selectmode= em->selectmode;
400                         EM_selectmode_set(em);
401                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
402                         ED_undo_push(C, "Selectmode Set: Face");
403                 }
404                 break;  
405
406         case B_MAN_TRANS:
407                 if( shift==0 || v3d->twtype==0) {
408                         v3d->twtype= V3D_MANIP_TRANSLATE;
409                 }
410                 ED_area_tag_redraw(sa);
411                 break;
412         case B_MAN_ROT:
413                 if( shift==0 || v3d->twtype==0) {
414                         v3d->twtype= V3D_MANIP_ROTATE;
415                 }
416                 ED_area_tag_redraw(sa);
417                 break;
418         case B_MAN_SCALE:
419                 if( shift==0 || v3d->twtype==0) {
420                         v3d->twtype= V3D_MANIP_SCALE;
421                 }
422                 ED_area_tag_redraw(sa);
423                 break;
424         case B_NDOF:
425                 ED_area_tag_redraw(sa);
426                 break;
427         case B_MAN_MODE:
428                 ED_area_tag_redraw(sa);
429                 break;
430         default:
431                 break;
432         }
433
434         if(obedit && obedit->type==OB_MESH)
435                 BKE_mesh_end_editmesh(obedit->data, em);
436 }
437
438 /* Returns the icon associated with an object mode */
439 static int object_mode_icon(int mode)
440 {
441         EnumPropertyItem *item = object_mode_items;
442         
443         while(item->name != NULL) {
444                 if(item->value == mode)
445                         return item->icon;
446                 ++item;
447         }
448
449         return ICON_OBJECT_DATAMODE;
450 }
451
452 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
453 {
454         Object *obedit = CTX_data_edit_object(C);
455         uiBlock *block= uiLayoutGetBlock(layout);
456
457         uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
458
459         if(obedit && (obedit->type == OB_MESH)) {
460                 EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
461                 uiLayout *row;
462
463                 row= uiLayoutRow(layout, 1);
464                 block= uiLayoutGetBlock(row);
465                 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");
466                 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");
467                 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");
468
469                 BKE_mesh_end_editmesh(obedit->data, em);
470         }
471 }
472
473 #define TIP_(msgid) UI_translate_do_tooltip(msgid)
474 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
475 {
476         bScreen *screen= CTX_wm_screen(C);
477         ScrArea *sa= CTX_wm_area(C);
478         View3D *v3d= sa->spacedata.first;
479         Scene *scene= CTX_data_scene(C);
480         ToolSettings *ts= CTX_data_tool_settings(C);
481         PointerRNA v3dptr, toolsptr, sceneptr;
482         Object *ob= OBACT;
483         Object *obedit = CTX_data_edit_object(C);
484         uiBlock *block;
485         uiBut *but;
486         uiLayout *row;
487         const float dpi_fac= UI_DPI_FAC;
488         
489         RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr);        
490         RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr);
491         RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr);
492
493         block= uiLayoutGetBlock(layout);
494         uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
495
496         /* other buttons: */
497         uiBlockSetEmboss(block, UI_EMBOSS);
498         
499         /* mode */
500         if(ob)
501                 v3d->modeselect = ob->mode;
502         else
503                 v3d->modeselect = OB_MODE_OBJECT;
504
505         uiBlockBeginAlign(block);
506         uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , 
507                           0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_(N_("Mode")));
508         uiBlockEndAlign(block);
509         
510         /* Draw type */
511         uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
512
513         if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) {
514                 /* Manipulators aren't used in weight paint mode */
515                 
516                 PointerRNA meshptr;
517
518                 RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
519                 if(ob->mode & (OB_MODE_TEXTURE_PAINT|OB_MODE_VERTEX_PAINT)) {
520                         uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
521                 }
522                 else {
523                         
524                         row= uiLayoutRow(layout, 1);
525                         uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
526                         uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
527                 }
528         } else {
529                 const char *str_menu;
530
531                 row= uiLayoutRow(layout, 1);
532                 uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
533                 uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
534
535                 /* Transform widget / manipulators */
536                 row= uiLayoutRow(layout, 1);
537                 uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
538                 block= uiLayoutGetBlock(row);
539                 
540                 if(v3d->twflag & V3D_USE_MANIPULATOR) {
541                         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_(N_("Translate manipulator mode")));
542                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
543                         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_(N_("Rotate manipulator mode")));
544                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
545                         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_(N_("Scale manipulator mode")));
546                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
547                 }
548                         
549                 if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
550                         v3d->twmode = 0;
551                 }
552                         
553                 str_menu = BIF_menustringTransformOrientation(C, N_("Orientation"));
554                 but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, TIP_(N_("Transform Orientation")));
555                 uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
556                 MEM_freeN((void *)str_menu);
557         }
558
559         if(obedit==NULL && v3d->localvd==NULL) {
560                 unsigned int ob_lay = ob ? ob->lay : 0;
561                 
562                 /* Layers */
563                 if (v3d->scenelock)
564                         uiTemplateLayers(layout, &sceneptr, "layers", &v3dptr, "layers_used", ob_lay);
565                 else
566                         uiTemplateLayers(layout, &v3dptr, "layers", &v3dptr, "layers_used", ob_lay);
567
568                 /* Scene lock */
569                 uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
570         }
571         
572         uiTemplateEditModeSelection(layout, C);
573 }
574 #undef TIP_