svn merge -r41650:41655 ^/trunk/blender --- cycles merge, this wont copile, still...
[blender.git] / release / scripts / startup / bl_ui / space_info.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu
22
23
24 class INFO_HT_header(Header):
25     bl_space_type = 'INFO'
26
27     def draw(self, context):
28         layout = self.layout
29
30         window = context.window
31         scene = context.scene
32         rd = scene.render
33
34         row = layout.row(align=True)
35         row.template_header()
36
37         if context.area.show_menus:
38             sub = row.row(align=True)
39             sub.menu("INFO_MT_file")
40             sub.menu("INFO_MT_add")
41             if rd.use_game_engine:
42                 sub.menu("INFO_MT_game")
43             else:
44                 sub.menu("INFO_MT_render")
45             sub.menu("INFO_MT_help")
46
47         if window.screen.show_fullscreen:
48             layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
49             layout.separator()
50         else:
51             layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
52             layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
53
54         layout.separator()
55
56         if rd.has_multiple_engines:
57             layout.prop(rd, "engine", text="")
58
59         layout.separator()
60
61         layout.template_running_jobs()
62
63         layout.template_reports_banner()
64
65         row = layout.row(align=True)
66         row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
67         row.label(text=scene.statistics())
68
69         # XXX: this should be right-aligned to the RHS of the region
70         layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
71
72         # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!!
73         """
74         sinfo = context.space_data
75         row = layout.row(align=True)
76         row.prop(sinfo, "show_report_debug", text="Debug")
77         row.prop(sinfo, "show_report_info", text="Info")
78         row.prop(sinfo, "show_report_operator", text="Operators")
79         row.prop(sinfo, "show_report_warning", text="Warnings")
80         row.prop(sinfo, "show_report_error", text="Errors")
81
82         row = layout.row()
83         row.enabled = sinfo.show_report_operator
84         row.operator("info.report_replay")
85
86         row.menu("INFO_MT_report")
87         """
88
89
90 class INFO_MT_report(Menu):
91     bl_label = "Report"
92
93     def draw(self, context):
94         layout = self.layout
95
96         layout.operator("console.select_all_toggle")
97         layout.operator("console.select_border")
98         layout.operator("console.report_delete")
99         layout.operator("console.report_copy")
100
101
102 class INFO_MT_file(Menu):
103     bl_label = "File"
104
105     def draw(self, context):
106         layout = self.layout
107
108         layout.operator_context = 'EXEC_AREA'
109         layout.operator("wm.read_homefile", text="New", icon='NEW')
110         layout.operator_context = 'INVOKE_AREA'
111         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
112         layout.menu("INFO_MT_file_open_recent")
113         layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
114         layout.operator("wm.recover_auto_save", text="Recover Auto Save...")
115
116         layout.separator()
117
118         layout.operator_context = 'INVOKE_AREA'
119         layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK').check_existing = False
120         layout.operator_context = 'INVOKE_AREA'
121         layout.operator("wm.save_as_mainfile", text="Save As...")
122         layout.operator_context = 'INVOKE_AREA'
123         layout.operator("wm.save_as_mainfile", text="Save Copy...").copy = True
124
125         layout.separator()
126
127         layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
128
129         layout.operator_context = 'EXEC_AREA'
130         layout.operator("wm.save_homefile")
131         layout.operator("wm.read_factory_settings")
132
133         layout.separator()
134
135         layout.operator_context = 'INVOKE_AREA'
136         layout.operator("wm.link_append", text="Link")
137         props = layout.operator("wm.link_append", text="Append")
138         props.link = False
139         props.instance_groups = False
140
141         layout.separator()
142
143         layout.menu("INFO_MT_file_import")
144         layout.menu("INFO_MT_file_export")
145
146         layout.separator()
147
148         layout.menu("INFO_MT_file_external_data")
149
150         layout.separator()
151
152         layout.operator_context = 'EXEC_AREA'
153         layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
154
155
156 class INFO_MT_file_import(Menu):
157     bl_idname = "INFO_MT_file_import"
158     bl_label = "Import"
159
160     def draw(self, context):
161         if hasattr(bpy.types, "WM_OT_collada_import"):
162             self.layout.operator("wm.collada_import", text="COLLADA (.dae)")
163
164
165 class INFO_MT_file_export(Menu):
166     bl_idname = "INFO_MT_file_export"
167     bl_label = "Export"
168
169     def draw(self, context):
170         if hasattr(bpy.types, "WM_OT_collada_export"):
171             self.layout.operator("wm.collada_export", text="COLLADA (.dae)")
172
173         self.layout.operator("export_mesh.wavefront", text="Wavefront (.obj), BMesh")
174
175
176 class INFO_MT_file_external_data(Menu):
177     bl_label = "External Data"
178
179     def draw(self, context):
180         layout = self.layout
181
182         layout.operator("file.pack_all", text="Pack into .blend file")
183         layout.operator("file.unpack_all", text="Unpack into Files")
184
185         layout.separator()
186
187         layout.operator("file.make_paths_relative")
188         layout.operator("file.make_paths_absolute")
189         layout.operator("file.report_missing_files")
190         layout.operator("file.find_missing_files")
191
192
193 class INFO_MT_mesh_add(Menu):
194     bl_idname = "INFO_MT_mesh_add"
195     bl_label = "Mesh"
196
197     def draw(self, context):
198         layout = self.layout
199
200         layout.operator_context = 'INVOKE_REGION_WIN'
201         layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
202         layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
203         layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
204         layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
205         layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
206         layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
207         layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
208         layout.separator()
209         layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
210         layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
211         layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
212
213
214 class INFO_MT_curve_add(Menu):
215     bl_idname = "INFO_MT_curve_add"
216     bl_label = "Curve"
217
218     def draw(self, context):
219         layout = self.layout
220
221         layout.operator_context = 'INVOKE_REGION_WIN'
222         layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
223         layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
224         layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
225         layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
226         layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
227
228
229 class INFO_MT_edit_curve_add(Menu):
230     bl_idname = "INFO_MT_edit_curve_add"
231     bl_label = "Add"
232
233     def draw(self, context):
234         is_surf = context.active_object.type == 'SURFACE'
235
236         layout = self.layout
237         layout.operator_context = 'INVOKE_REGION_WIN'
238
239         if is_surf:
240             INFO_MT_surface_add.draw(self, context)
241         else:
242             INFO_MT_curve_add.draw(self, context)
243
244
245 class INFO_MT_surface_add(Menu):
246     bl_idname = "INFO_MT_surface_add"
247     bl_label = "Surface"
248
249     def draw(self, context):
250         layout = self.layout
251
252         layout.operator_context = 'INVOKE_REGION_WIN'
253         layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
254         layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
255         layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
256         layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
257         layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
258         layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
259
260
261 class INFO_MT_armature_add(Menu):
262     bl_idname = "INFO_MT_armature_add"
263     bl_label = "Armature"
264
265     def draw(self, context):
266         layout = self.layout
267
268         layout.operator_context = 'INVOKE_REGION_WIN'
269         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
270
271
272 class INFO_MT_add(Menu):
273     bl_label = "Add"
274
275     def draw(self, context):
276         layout = self.layout
277
278         layout.operator_context = 'EXEC_SCREEN'
279
280         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
281         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
282
283         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
284         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
285         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
286         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
287         layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
288         layout.operator_context = 'INVOKE_REGION_WIN'
289         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
290         layout.separator()
291
292         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
293         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
294         layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY'
295         layout.separator()
296
297         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
298         layout.separator()
299
300         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
301         layout.operator_context = 'EXEC_SCREEN'
302         layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
303         layout.separator()
304
305         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
306         layout.separator()
307
308         if(len(bpy.data.groups) > 10):
309             layout.operator_context = 'INVOKE_DEFAULT'
310             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
311         else:
312             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
313
314
315 class INFO_MT_game(Menu):
316     bl_label = "Game"
317
318     def draw(self, context):
319         layout = self.layout
320
321         gs = context.scene.game_settings
322
323         layout.operator("view3d.game_start")
324
325         layout.separator()
326
327         layout.prop(gs, "show_debug_properties")
328         layout.prop(gs, "show_framerate_profile")
329         layout.prop(gs, "show_physics_visualization")
330         layout.prop(gs, "use_deprecation_warnings")
331         layout.prop(gs, "use_animation_record")
332         layout.separator()
333         layout.prop(gs, "use_auto_start")
334
335
336 class INFO_MT_render(Menu):
337     bl_label = "Render"
338
339     def draw(self, context):
340         layout = self.layout
341
342         layout.operator("render.render", text="Render Image", icon='RENDER_STILL')
343         layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION').animation = True
344
345         layout.separator()
346
347         layout.operator("render.opengl", text="OpenGL Render Image")
348         layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
349
350         layout.separator()
351
352         layout.operator("render.view_show")
353         layout.operator("render.play_rendered_anim")
354
355
356 class INFO_MT_help(Menu):
357     bl_label = "Help"
358
359     def draw(self, context):
360         import sys
361
362         layout = self.layout
363
364         layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
365         layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-260/'
366
367         layout.separator()
368
369         layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/'
370         layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = 'http://www.blender.org/e-shop'
371         layout.operator("wm.url_open", text="Developer Community", icon='URL').url = 'http://www.blender.org/community/get-involved/'
372         layout.operator("wm.url_open", text="User Community", icon='URL').url = 'http://www.blender.org/community/user-community/'
373         layout.separator()
374         layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = 'http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse'
375         layout.separator()
376
377         layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix
378         layout.operator("wm.operator_cheat_sheet", icon='TEXT')
379         layout.operator("wm.sysinfo", icon='TEXT')
380         layout.separator()
381         if sys.platform[:3] == "win":
382             layout.operator("wm.console_toggle", icon='CONSOLE')
383             layout.separator()
384         layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP')
385         layout.operator("logic.texface_convert", text="TexFace to Material Convert", icon='GAME')
386         layout.separator()
387         layout.operator("wm.splash", icon='BLENDER')
388
389 if __name__ == "__main__":  # only for live edit.
390     bpy.utils.register_module(__name__)