2.5 3D_View:
[blender-staging.git] / release / ui / space_view3d.py
1
2 import bpy
3
4 # ********** Header ****************
5
6 class VIEW3D_HT_header(bpy.types.Header):
7         __space_type__ = "VIEW_3D"
8
9         def draw(self, context):
10                 layout = self.layout
11
12                 layout.template_header()
13
14                 # menus
15                 if context.area.show_menus:
16                         row = layout.row()
17                         row.itemM("VIEW3D_MT_view")
18
19                 layout.template_header_3D()
20
21 # ********** Menu ****************
22
23 class VIEW3D_MT_view_navigation(bpy.types.Menu):
24         __space_type__ = "VIEW_3D"
25         __label__ = "Navigation"
26
27         def draw(self, context):
28                 layout = self.layout
29
30                 # layout.itemO("view3d.view_fly_mode")
31                 # layout.itemS()
32                 
33                 layout.items_enumO("view3d.view_orbit", "type")
34                 
35                 layout.itemS()
36                 
37                 layout.items_enumO("view3d.view_pan", "type")
38                 
39                 layout.itemS()
40                 
41                 layout.item_floatO("view3d.zoom", "delta", 1.0, text="Zoom In")
42                 layout.item_floatO("view3d.zoom", "delta", -1.0, text="Zoom Out")
43
44 class VIEW3D_MT_view(bpy.types.Menu):
45         __space_type__ = "VIEW_3D"
46         __label__ = "View"
47
48         def draw(self, context):
49                 layout = self.layout
50
51                 layout.itemO("view3d.properties", icon="ICON_MENU_PANEL")
52                 layout.itemO("view3d.toolbar", icon="ICON_MENU_PANEL")
53                 
54                 layout.itemS()
55                 
56                 layout.item_enumO("view3d.viewnumpad", "type", 'CAMERA')
57                 layout.item_enumO("view3d.viewnumpad", "type", 'TOP')
58                 layout.item_enumO("view3d.viewnumpad", "type", 'FRONT')
59                 layout.item_enumO("view3d.viewnumpad", "type", 'RIGHT')
60                 
61                 # layout.itemM("VIEW3D_MT_view_cameras", text="Cameras")
62                 
63                 layout.itemS()
64
65                 layout.itemO("view3d.view_persportho")
66                 
67                 layout.itemS()
68                 
69                 # layout.itemO("view3d.view_show_all_layers")
70                 
71                 # layout.itemS()
72                 
73                 # layout.itemO("view3d.view_local_view")
74                 # layout.itemO("view3d.view_global_view")
75                 
76                 # layout.itemS()
77                 
78                 layout.itemM("VIEW3D_MT_view_navigation")
79                 # layout.itemM("VIEW3D_MT_view_align", text="Align View")
80                 
81                 layout.itemS()
82
83                 layout.operator_context = "INVOKE_REGION_WIN"
84
85                 layout.itemO("view3d.clip_border")
86                 layout.itemO("view3d.zoom_border")
87                 
88                 layout.itemS()
89                 
90                 layout.itemO("view3d.view_center")
91                 layout.itemO("view3d.view_all")
92                 
93                 layout.itemS()
94                 
95                 layout.itemO("screen.region_foursplit", text="Toggle Quad View")
96                 layout.itemO("screen.screen_full_area", text="Toggle Full Screen")
97
98 # ********** Select menus ****************
99
100 class VIEW3D_MT_select_objectmode(bpy.types.Menu):
101         __space_type__ = "VIEW_3D"
102         __label__ = "Select"
103
104         def draw(self, context):
105                 layout = self.layout
106
107                 layout.itemO("view3d.select_border")
108
109                 layout.itemS()
110
111                 layout.itemO("object.select_all_toggle", text="Select/Deselect All")
112                 layout.itemO("object.select_inverse", text="Inverse")
113                 layout.itemO("object.select_random", text="Random")
114                 layout.itemO("object.select_by_layer", text="Select All by Layer")
115                 layout.item_enumO("object.select_by_type", "type", "", text="Select All by Type")
116                 layout.item_enumO("object.select_grouped", "type", "", text="Select Grouped")
117
118 class VIEW3D_MT_select_posemode(bpy.types.Menu):
119         __space_type__ = "VIEW_3D"
120         __label__ = "Select"
121
122         def draw(self, context):
123                 layout = self.layout
124
125                 layout.itemO("view3d.select_border")
126
127                 layout.itemS()
128                 
129                 layout.itemO("pose.select_all_toggle", text="Select/Deselect All")
130                 layout.itemO("pose.select_inverse", text="Inverse")
131                 layout.itemO("pose.select_constraint_target", text="Constraint Target")
132                 
133                 layout.itemS()
134                 
135                 layout.item_enumO("pose.select_hierarchy", "direction", "PARENT")
136                 layout.item_enumO("pose.select_hierarchy", "direction", "CHILD")
137                 
138                 layout.itemS()
139                 
140                 layout.view3d_select_posemenu()
141
142 class VIEW3D_MT_select_particlemode(bpy.types.Menu):
143         __space_type__ = "VIEW_3D"
144         __label__ = "Select"
145
146         def draw(self, context):
147                 layout = self.layout
148
149                 layout.itemO("view3d.select_border")
150
151                 layout.itemS()
152                 
153                 layout.itemO("particle.select_all_toggle", text="Select/Deselect All")
154                 layout.itemO("particle.select_linked")
155                 
156                 layout.itemS()
157                 
158                 #layout.itemO("particle.select_last")
159                 #layout.itemO("particle.select_first")
160                 
161                 layout.itemO("particle.select_more")
162                 layout.itemO("particle.select_less")
163
164 class VIEW3D_MT_select_meshedit(bpy.types.Menu):
165         __space_type__ = "VIEW_3D"
166         __label__ = "Select"
167
168         def draw(self, context):
169                 layout = self.layout
170
171                 layout.itemO("view3d.select_border")
172
173                 layout.itemS()
174
175                 layout.itemO("mesh.select_all_toggle", text="Select/Deselect All")
176                 layout.itemO("mesh.select_inverse", text="Inverse")
177
178                 layout.itemS()
179
180                 layout.itemO("mesh.select_random", text="Random...")
181                 layout.itemO("mesh.edges_select_sharp", text="Sharp Edges")
182                 layout.itemO("mesh.faces_select_linked_flat", text="Linked Flat Faces")
183
184                 layout.itemS()
185
186                 layout.item_enumO("mesh.select_by_number_vertices", "type", "TRIANGLES", text="Triangles")
187                 layout.item_enumO("mesh.select_by_number_vertices", "type", "QUADS", text="Quads")
188                 layout.item_enumO("mesh.select_by_number_vertices", "type", "OTHER", text="Loose Verts/Edges")
189                 layout.itemO("mesh.select_similar", text="Similar...")
190
191                 layout.itemS()
192
193                 layout.itemO("mesh.select_less", text="Less")
194                 layout.itemO("mesh.select_more", text="More")
195
196                 layout.itemS()
197
198                 layout.itemO("mesh.select_linked", text="Linked")
199                 layout.itemO("mesh.select_vertex_path", text="Vertex Path")
200                 layout.itemO("mesh.loop_multi_select", text="Edge Loop")
201                 layout.item_booleanO("mesh.loop_multi_select", "ring", True, text="Edge Ring")
202
203                 layout.itemS()
204
205                 layout.itemO("mesh.loop_to_region")
206                 layout.itemO("mesh.region_to_loop")
207
208 class VIEW3D_MT_select_curveedit(bpy.types.Menu):
209         __space_type__ = "VIEW_3D"
210         __label__ = "Select"
211
212         def draw(self, context):
213                 layout = self.layout
214
215                 layout.itemO("view3d.select_border")
216                 layout.itemO("view3d.select_circle")
217
218                 layout.itemS()
219                 
220                 layout.itemO("curve.select_all_toggle", text="Select/Deselect All")
221                 layout.itemO("curve.select_inverse")
222                 layout.itemO("curve.select_random")
223                 layout.itemO("curve.select_every_nth")
224
225                 layout.itemS()
226                 
227                 layout.itemO("curve.de_select_first")
228                 layout.itemO("curve.de_select_last")
229                 layout.itemO("curve.select_next")
230                 layout.itemO("curve.select_previous")
231
232                 layout.itemS()
233                 
234                 layout.itemO("curve.select_more")
235                 layout.itemO("curve.select_less")
236
237 class VIEW3D_MT_select_surfaceedit(bpy.types.Menu):
238         __space_type__ = "VIEW_3D"
239         __label__ = "Select"
240
241         def draw(self, context):
242                 layout = self.layout
243
244                 layout.itemO("view3d.select_border")
245                 layout.itemO("view3d.select_circle")
246
247                 layout.itemS()
248                 
249                 layout.itemO("curve.select_all_toggle", text="Select/Deselect All")
250                 layout.itemO("curve.select_inverse")
251                 layout.itemO("curve.select_random")
252                 layout.itemO("curve.select_every_nth")
253
254                 layout.itemS()
255                 
256                 layout.itemO("curve.select_row")
257
258                 layout.itemS()
259                 
260                 layout.itemO("curve.select_more")
261                 layout.itemO("curve.select_less")
262
263 class VIEW3D_MT_select_mballedit(bpy.types.Menu):
264         __space_type__ = "VIEW_3D"
265         __label__ = "Select"
266
267         def draw(self, context):
268                 layout = self.layout
269
270                 layout.itemO("view3d.select_border")
271                 
272                 layout.itemS()
273                 
274                 layout.itemL(text="Select/Deselect All")
275                 layout.itemL(text="Inverse")
276                 
277                 layout.itemS()
278                 
279                 layout.itemL(text="Random")
280
281 class VIEW3D_MT_select_latticeedit(bpy.types.Menu):
282         __space_type__ = "VIEW_3D"
283         __label__ = "Select"
284
285         def draw(self, context):
286                 layout = self.layout
287
288                 layout.itemO("view3d.select_border")
289
290                 layout.itemS()
291                 
292                 layout.itemO("lattice.select_all_toggle", text="Select/Deselect All")
293
294 class VIEW3D_MT_select_armatureedit(bpy.types.Menu):
295         __space_type__ = "VIEW_3D"
296         __label__ = "Select"
297
298         def draw(self, context):
299                 layout = self.layout
300
301                 layout.itemO("view3d.select_border")
302
303                 layout.itemS()
304                 
305                 layout.itemO("armature.select_all_toggle", text="Select/Deselect All")
306                 layout.itemO("armature.select_inverse", text="Inverse")
307
308                 layout.itemS()
309                 
310                 layout.item_enumO("armature.select_hierarchy", "direction", "PARENT")
311                 layout.item_enumO("armature.select_hierarchy", "direction", "CHILD")
312                 
313                 layout.itemS()
314                 
315                 layout.view3d_select_armaturemenu()
316
317 class VIEW3D_MT_select_facesel(bpy.types.Menu):
318         __space_type__ = "VIEW_3D"
319         __label__ = "Select"
320
321         def draw(self, context):
322                 layout = self.layout
323
324                 layout.view3d_select_faceselmenu()
325
326 class VIEW3D_HT_header(bpy.types.Header):
327         __space_type__ = "VIEW_3D"
328
329         def draw(self, context):
330                 view = context.space_data
331                 mode_string = context.mode_string
332                 layout = self.layout
333
334                 layout.template_header()
335                 
336                 # menus
337                 if context.area.show_menus:
338                         row = layout.row()
339
340                         row.itemM("VIEW3D_MT_view")
341                         
342                         selectmenu = "VIEW3D_MT_select_%s" % mode_string
343                         if selectmenu in dir(bpy.types):
344                                 layout.itemM(selectmenu)
345
346                 layout.template_header_3D()
347
348 # ********** Panel ****************
349
350 class VIEW3D_PT_3dview_properties(bpy.types.Panel):
351         __space_type__ = "VIEW_3D"
352         __region_type__ = "UI"
353         __label__ = "View"
354
355         def poll(self, context):
356                 view = context.space_data
357                 return (view)
358
359         def draw(self, context):
360                 layout = self.layout
361                 
362                 view = context.space_data
363                 scene = context.scene
364                 
365                 col = layout.column()
366                 col.itemR(view, "camera")
367                 col.itemR(view, "lens")
368                 
369                 layout.itemL(text="Clip:")
370                 col = layout.column(align=True)
371                 col.itemR(view, "clip_start", text="Start")
372                 col.itemR(view, "clip_end", text="End")
373                 
374                 layout.itemL(text="Grid:")
375                 col = layout.column(align=True)
376                 col.itemR(view, "grid_lines", text="Lines")
377                 col.itemR(view, "grid_spacing", text="Spacing")
378                 col.itemR(view, "grid_subdivisions", text="Subdivisions")
379                 
380                 layout.column().itemR(scene, "cursor_location", text="3D Cursor:")
381                 
382 class VIEW3D_PT_3dview_display(bpy.types.Panel):
383         __space_type__ = "VIEW_3D"
384         __region_type__ = "UI"
385         __label__ = "Display"
386
387         def poll(self, context):
388                 view = context.space_data
389                 return (view)
390
391         def draw(self, context):
392                 layout = self.layout
393                 view = context.space_data
394                 
395                 col = layout.column()
396                 col.itemR(view, "display_floor", text="Grid Floor")
397                 col.itemR(view, "display_x_axis", text="X Axis")
398                 col.itemR(view, "display_y_axis", text="Y Axis")
399                 col.itemR(view, "display_z_axis", text="Z Axis")
400                 col.itemR(view, "outline_selected")
401                 col.itemR(view, "all_object_centers")
402                 col.itemR(view, "relationship_lines")
403                 col.itemR(view, "textured_solid")
404                 
405                 layout.itemS()
406                 
407                 layout.itemO("screen.region_foursplit")
408                 
409                 col = layout.column()
410                 col.itemR(view, "lock_rotation")
411                 col.itemR(view, "box_preview")
412                 col.itemR(view, "box_clip")
413         
414 class VIEW3D_PT_background_image(bpy.types.Panel):
415         __space_type__ = "VIEW_3D"
416         __region_type__ = "UI"
417         __label__ = "Background Image"
418         __default_closed__ = True
419
420         def poll(self, context):
421                 view = context.space_data
422                 bg = context.space_data.background_image
423                 return (view)
424
425         def draw_header(self, context):
426                 layout = self.layout
427                 view = context.space_data
428
429                 layout.itemR(view, "display_background_image", text="")
430
431         def draw(self, context):
432                 layout = self.layout
433                 
434                 view = context.space_data
435                 bg = view.background_image
436
437                 if bg:
438                         layout.active = view.display_background_image
439
440                         col = layout.column()
441                         col.itemR(bg, "image", text="")
442                         #col.itemR(bg, "image_user")
443                         col.itemR(bg, "size")
444                         col.itemR(bg, "transparency", slider=True)
445                         col.itemL(text="Offset:")
446                         
447                         col = layout.column(align=True)
448                         col.itemR(bg, "x_offset", text="X")
449                         col.itemR(bg, "y_offset", text="Y")
450
451 bpy.types.register(VIEW3D_MT_view_navigation)
452 bpy.types.register(VIEW3D_MT_view)
453 bpy.types.register(VIEW3D_MT_select_objectmode)
454 bpy.types.register(VIEW3D_MT_select_posemode)
455 bpy.types.register(VIEW3D_MT_select_particlemode)
456 bpy.types.register(VIEW3D_MT_select_meshedit)
457 bpy.types.register(VIEW3D_MT_select_curveedit)
458 bpy.types.register(VIEW3D_MT_select_surfaceedit)
459 bpy.types.register(VIEW3D_MT_select_mballedit)
460 bpy.types.register(VIEW3D_MT_select_latticeedit)
461 bpy.types.register(VIEW3D_MT_select_armatureedit)
462 bpy.types.register(VIEW3D_MT_select_facesel)
463 bpy.types.register(VIEW3D_HT_header)
464 bpy.types.register(VIEW3D_PT_3dview_properties)
465 bpy.types.register(VIEW3D_PT_3dview_display)
466 bpy.types.register(VIEW3D_PT_background_image)