svn merge ^/trunk/blender -r43693:43733
[blender-staging.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 #include "BKE_tessmesh.h"
59
60 #include "ED_mesh.h"
61 #include "ED_util.h"
62 #include "ED_screen.h"
63 #include "ED_transform.h"
64 #include "ED_types.h"
65
66 #include "WM_api.h"
67 #include "WM_types.h"
68
69 #include "RNA_define.h"
70 #include "RNA_enum_types.h"
71
72 #include "UI_interface.h"
73 #include "UI_resources.h"
74
75 #include "view3d_intern.h"
76
77
78 /* View3d->modeselect 
79  * This is a bit of a dodgy hack to enable a 'mode' menu with icons+labels
80  * rather than those buttons.
81  * I know the implementation's not good - it's an experiment to see if this
82  * approach would work well
83  *
84  * This can be cleaned when I make some new 'mode' icons.
85  */
86
87 /* view3d handler codes */
88 #define VIEW3D_HANDLER_BACKGROUND       1
89 #define VIEW3D_HANDLER_PROPERTIES       2
90 #define VIEW3D_HANDLER_OBJECT           3
91 #define VIEW3D_HANDLER_PREVIEW          4
92 #define VIEW3D_HANDLER_MULTIRES         5
93 #define VIEW3D_HANDLER_TRANSFORM        6
94 #define VIEW3D_HANDLER_GREASEPENCIL 7
95 #define VIEW3D_HANDLER_BONESKETCH       8
96
97 /* end XXX ************* */
98
99 static void do_view3d_header_buttons(bContext *C, void *arg, int event);
100
101 #define B_SCENELOCK 101
102 #define B_FULL          102
103 #define B_HOME          103
104 #define B_VIEWBUT       104
105 #define B_PERSP         105
106 #define B_MODESELECT 108
107 #define B_SEL_VERT      110
108 #define B_SEL_EDGE      111
109 #define B_SEL_FACE      112
110 #define B_MAN_TRANS     116
111 #define B_MAN_ROT       117
112 #define B_MAN_SCALE     118
113 #define B_NDOF          119     
114 #define B_MAN_MODE      120
115 #define B_REDR          122
116 #define B_NOP           123
117
118 // XXX quickly ported across
119 static void handle_view3d_lock(bContext *C) 
120 {
121         Main *bmain= CTX_data_main(C);
122         Scene *scene= CTX_data_scene(C);
123         ScrArea *sa= CTX_wm_area(C);
124         View3D *v3d= CTX_wm_view3d(C);
125         
126         if (v3d != NULL && sa != NULL) {
127                 if(v3d->localvd==NULL && v3d->scenelock && sa->spacetype==SPACE_VIEW3D) {
128                         /* copy to scene */
129                         scene->lay= v3d->lay;
130                         scene->layact= v3d->layact;
131                         scene->camera= v3d->camera;
132
133                         /* not through notifiery, listener don't have context
134                            and non-open screens or spaces need to be updated too */
135                         BKE_screen_view3d_main_sync(&bmain->screen, scene);
136                         
137                         /* notifiers for scene update */
138                         WM_event_add_notifier(C, NC_SCENE|ND_LAYER, scene);
139                 }
140         }
141 }
142
143 /* layer code is on three levels actually:
144 - here for operator
145 - uiTemplateLayers in interface/ code for buttons
146 - ED_view3d_scene_layer_set for RNA
147  */
148 static void view3d_layers_editmode_ensure(Scene *scene, View3D *v3d)
149 {
150         /* sanity check - when in editmode disallow switching the editmode layer off since its confusing
151          * an alternative would be to always draw the editmode object. */
152         if(scene->obedit && (scene->obedit->lay & v3d->lay)==0) {
153                 int bit;
154                 for(bit=0; bit<32; bit++) {
155                         if(scene->obedit->lay & (1<<bit)) {
156                                 v3d->lay |= 1<<bit;
157                                 break;
158                         }
159                 }
160         }
161 }
162
163 static int view3d_layers_exec(bContext *C, wmOperator *op)
164 {
165         Scene *scene= CTX_data_scene(C);
166         ScrArea *sa= CTX_wm_area(C);
167         View3D *v3d= sa->spacedata.first;
168         int nr= RNA_int_get(op->ptr, "nr");
169         int toggle= RNA_boolean_get(op->ptr, "toggle");
170         
171         if(nr < 0)
172                 return OPERATOR_CANCELLED;
173
174         if(nr == 0) {
175                 /* all layers */
176                 if(!v3d->layact)
177                         v3d->layact= 1;
178
179                 if (toggle && v3d->lay == ((1<<20)-1)) {
180                         /* return to active layer only */
181                         v3d->lay = v3d->layact;
182
183                         view3d_layers_editmode_ensure(scene, v3d);
184                 }
185                 else {
186                         v3d->lay |= (1<<20)-1;
187                 }               
188         }
189         else {
190                 int bit;
191                 nr--;
192
193                 if(RNA_boolean_get(op->ptr, "extend")) {
194                         if(toggle && v3d->lay & (1<<nr) && (v3d->lay & ~(1<<nr)))
195                                 v3d->lay &= ~(1<<nr);
196                         else
197                                 v3d->lay |= (1<<nr);
198                 } else {
199                         v3d->lay = (1<<nr);
200                 }
201
202                 view3d_layers_editmode_ensure(scene, v3d);
203
204                 /* set active layer, ensure to always have one */
205                 if(v3d->lay & (1<<nr))
206                    v3d->layact= 1<<nr;
207                 else if((v3d->lay & v3d->layact)==0) {
208                         for(bit=0; bit<32; bit++) {
209                                 if(v3d->lay & (1<<bit)) {
210                                         v3d->layact= 1<<bit;
211                                         break;
212                                 }
213                         }
214                 }
215         }
216         
217         if(v3d->scenelock) handle_view3d_lock(C);
218         
219         DAG_on_visible_update(CTX_data_main(C), FALSE);
220
221         ED_area_tag_redraw(sa);
222         
223         return OPERATOR_FINISHED;
224 }
225
226 /* applies shift and alt, lazy coding or ok? :) */
227 /* the local per-keymap-entry keymap will solve it */
228 static int view3d_layers_invoke(bContext *C, wmOperator *op, wmEvent *event)
229 {
230         if(event->ctrl || event->oskey)
231                 return OPERATOR_PASS_THROUGH;
232         
233         if(event->shift)
234                 RNA_boolean_set(op->ptr, "extend", TRUE);
235         else
236                 RNA_boolean_set(op->ptr, "extend", FALSE);
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[512];
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 ||
323              modifiers_findByType(ob, eModifierType_Cloth) ||
324              modifiers_findByType(ob, eModifierType_Softbody))
325         {
326                 str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
327         }
328         (void)str;
329         return (string);
330 }
331
332
333 static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
334 {
335         wmWindow *win= CTX_wm_window(C);
336         ToolSettings *ts= CTX_data_tool_settings(C);
337         ScrArea *sa= CTX_wm_area(C);
338         View3D *v3d= sa->spacedata.first;
339         Object *obedit = CTX_data_edit_object(C);
340         BMEditMesh *em= NULL;
341         int ctrl= win->eventstate->ctrl, shift= win->eventstate->shift;
342         PointerRNA props_ptr;
343         
344         if(obedit && obedit->type==OB_MESH) {
345                 em= ((Mesh *)obedit->data)->edit_btmesh;
346         }
347         /* watch it: if sa->win does not exist, check that when calling direct drawing routines */
348
349         switch(event) {
350         case B_REDR:
351                 ED_area_tag_redraw(sa);
352                 break;
353                 
354         case B_MODESELECT:
355                 WM_operator_properties_create(&props_ptr, "OBJECT_OT_mode_set");
356                 RNA_enum_set(&props_ptr, "mode", v3d->modeselect);
357                 WM_operator_name_call(C, "OBJECT_OT_mode_set", WM_OP_EXEC_REGION_WIN, &props_ptr);
358                 WM_operator_properties_free(&props_ptr);
359                 break;          
360                 
361         case B_SEL_VERT:
362                 if(em) {
363                         if(shift==0 || em->selectmode==0)
364                                 em->selectmode= SCE_SELECT_VERTEX;
365                         ts->selectmode= em->selectmode;
366                         EDBM_selectmode_set(em);
367                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
368                         ED_undo_push(C, "Selectmode Set: Vertex");
369                 }
370                 break;
371         case B_SEL_EDGE:
372                 if(em) {
373                         if(shift==0 || em->selectmode==0){
374                                 if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){
375                                         if(ctrl) EDBM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); 
376                                 }
377                                 em->selectmode = SCE_SELECT_EDGE;
378                         }
379                         ts->selectmode= em->selectmode;
380                         EDBM_selectmode_set(em);
381                         WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
382                         ED_undo_push(C, "Selectmode Set: Edge");
383                 }
384                 break;
385         case B_SEL_FACE:
386                 if(em) {
387                         if( shift==0 || em->selectmode==0){
388                                 if( ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((ts->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){
389                                         if(ctrl) EDBM_convertsel(em, (ts->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE);
390                                 }
391                                 em->selectmode = SCE_SELECT_FACE;
392                         }
393                         ts->selectmode= em->selectmode;
394                         EDBM_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
429 /* Returns the icon associated with an object mode */
430 static int object_mode_icon(int mode)
431 {
432         EnumPropertyItem *item = object_mode_items;
433         
434         while(item->name != NULL) {
435                 if(item->value == mode)
436                         return item->icon;
437                 ++item;
438         }
439
440         return ICON_OBJECT_DATAMODE;
441 }
442
443 void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
444 {
445         Object *obedit = CTX_data_edit_object(C);
446         uiBlock *block= uiLayoutGetBlock(layout);
447
448         uiBlockSetHandleFunc(block, do_view3d_header_buttons, NULL);
449
450         if(obedit && (obedit->type == OB_MESH)) {
451                 BMEditMesh *em= ((Mesh *)obedit->data)->edit_btmesh;
452                 uiLayout *row;
453
454                 row= uiLayoutRow(layout, 1);
455                 block= uiLayoutGetBlock(row);
456                 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");
457                 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");
458                 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");
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         }
491         else {
492                 v3d->modeselect = OB_MODE_OBJECT;
493         }
494
495         row= uiLayoutRow(layout, 1);
496         uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , 
497                           0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_("Mode"));
498         
499         /* Draw type */
500         uiItemR(layout, &v3dptr, "viewport_shade", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
501
502         if (obedit==NULL && ((ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)))) {
503                 /* Manipulators aren't used in weight paint mode */
504                 
505                 PointerRNA meshptr;
506
507                 RNA_pointer_create(&ob->id, &RNA_Mesh, ob->data, &meshptr);
508                 if(ob->mode & (OB_MODE_TEXTURE_PAINT|OB_MODE_VERTEX_PAINT)) {
509                         uiItemR(layout, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
510                 }
511                 else {
512                         
513                         row= uiLayoutRow(layout, 1);
514                         uiItemR(row, &meshptr, "use_paint_mask", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
515                         uiItemR(row, &meshptr, "use_paint_mask_vertex", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
516                 }
517         } else {
518                 const char *str_menu;
519
520                 row= uiLayoutRow(layout, 1);
521                 uiItemR(row, &v3dptr, "pivot_point", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
522
523                 /* pose/object only however we want to allow in weight paint mode too
524                  * so dont be totally strict and just check not-editmode for now */
525                 if (obedit == NULL) {
526                         uiItemR(row, &v3dptr, "use_pivot_point_align", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
527                 }
528
529                 /* Transform widget / manipulators */
530                 row= uiLayoutRow(layout, 1);
531                 uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
532                 block= uiLayoutGetBlock(row);
533                 
534                 if(v3d->twflag & V3D_USE_MANIPULATOR) {
535                         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"));
536                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
537                         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"));
538                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
539                         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"));
540                         uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
541                 }
542                         
543                 if (v3d->twmode > (BIF_countTransformOrientation(C) - 1) + V3D_MANIP_CUSTOM) {
544                         v3d->twmode = 0;
545                 }
546                         
547                 str_menu = BIF_menustringTransformOrientation(C, "Orientation");
548                 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"));
549                 uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
550                 MEM_freeN((void *)str_menu);
551         }
552
553         if(obedit==NULL && v3d->localvd==NULL) {
554                 unsigned int ob_lay = ob ? ob->lay : 0;
555
556                 /* Layers */
557                 uiTemplateLayers(layout, v3d->scenelock ? &sceneptr : &v3dptr, "layers", &v3dptr, "layers_used", ob_lay);
558
559                 /* Scene lock */
560                 uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
561         }
562         
563         uiTemplateEditModeSelection(layout, C);
564 }