5a570d18312636188ec05652196af91d2b0de19c
[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_window")
46             sub.menu("INFO_MT_help")
47
48         if window.screen.show_fullscreen:
49             layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
50             layout.separator()
51         else:
52             layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
53             layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
54
55         layout.separator()
56
57         if rd.has_multiple_engines:
58             layout.prop(rd, "engine", text="")
59
60         layout.separator()
61
62         layout.template_running_jobs()
63
64         layout.template_reports_banner()
65
66         row = layout.row(align=True)
67
68         if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False:
69             layout.operator_context = 'EXEC_DEFAULT'
70             row.label("Auto-run disabled: %s" % bpy.app.autoexec_fail_message, icon='ERROR')
71             if bpy.data.is_saved:
72                 props = row.operator("wm.open_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
73                 props.filepath = bpy.data.filepath
74                 props.use_scripts = True
75
76             row.operator("script.autoexec_warn_clear", text="Ignore")
77             return
78
79         row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
80         row.label(text=scene.statistics(), translate=False)
81
82         # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!!
83         """
84         sinfo = context.space_data
85         row = layout.row(align=True)
86         row.prop(sinfo, "show_report_debug", text="Debug")
87         row.prop(sinfo, "show_report_info", text="Info")
88         row.prop(sinfo, "show_report_operator", text="Operators")
89         row.prop(sinfo, "show_report_warning", text="Warnings")
90         row.prop(sinfo, "show_report_error", text="Errors")
91
92         row = layout.row()
93         row.enabled = sinfo.show_report_operator
94         row.operator("info.report_replay")
95
96         row.menu("INFO_MT_report")
97         """
98
99
100 class INFO_MT_report(Menu):
101     bl_label = "Report"
102
103     def draw(self, context):
104         layout = self.layout
105
106         layout.operator("console.select_all_toggle")
107         layout.operator("console.select_border")
108         layout.operator("console.report_delete")
109         layout.operator("console.report_copy")
110
111
112 class INFO_MT_file(Menu):
113     bl_label = "File"
114
115     def draw(self, context):
116         layout = self.layout
117
118         layout.operator_context = 'INVOKE_AREA'
119         layout.operator("wm.read_homefile", text="New", icon='NEW')
120         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
121         layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT')
122         layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
123         layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
124
125         layout.separator()
126
127         layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA'
128         layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
129
130         layout.operator_context = 'INVOKE_AREA'
131         layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
132         layout.operator_context = 'INVOKE_AREA'
133         layout.operator("wm.save_as_mainfile", text="Save Copy...", icon='SAVE_COPY').copy = True
134
135         layout.separator()
136
137         layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
138
139         layout.operator_context = 'INVOKE_AREA'
140         layout.operator("wm.save_homefile", icon='SAVE_PREFS')
141         layout.operator_context = 'EXEC_AREA'
142         layout.operator("wm.read_factory_settings", icon='LOAD_FACTORY')
143
144         layout.separator()
145
146         layout.operator_context = 'INVOKE_AREA'
147         layout.operator("wm.link_append", text="Link", icon='LINK_BLEND')
148         props = layout.operator("wm.link_append", text="Append", icon='APPEND_BLEND')
149         props.link = False
150         props.instance_groups = False
151
152         layout.separator()
153
154         layout.menu("INFO_MT_file_import", icon='IMPORT')
155         layout.menu("INFO_MT_file_export", icon='EXPORT')
156
157         layout.separator()
158
159         layout.menu("INFO_MT_file_external_data", icon='EXTERNAL_DATA')
160
161         layout.separator()
162
163         layout.operator_context = 'EXEC_AREA'
164         layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
165
166
167 class INFO_MT_file_import(Menu):
168     bl_idname = "INFO_MT_file_import"
169     bl_label = "Import"
170
171     def draw(self, context):
172         if bpy.app.build_options.collada:
173             self.layout.operator("wm.collada_import", text="Collada (Default) (.dae)")
174
175
176 class INFO_MT_file_export(Menu):
177     bl_idname = "INFO_MT_file_export"
178     bl_label = "Export"
179
180     def draw(self, context):
181         if bpy.app.build_options.collada:
182             self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)")
183
184
185 class INFO_MT_file_external_data(Menu):
186     bl_label = "External Data"
187
188     def draw(self, context):
189         layout = self.layout
190
191         layout.operator("file.pack_all", text="Pack into .blend file")
192         layout.operator("file.unpack_all", text="Unpack into Files")
193
194         layout.separator()
195
196         layout.operator("file.make_paths_relative")
197         layout.operator("file.make_paths_absolute")
198         layout.operator("file.report_missing_files")
199         layout.operator("file.find_missing_files")
200
201
202 class INFO_MT_mesh_add(Menu):
203     bl_idname = "INFO_MT_mesh_add"
204     bl_label = "Mesh"
205
206     def draw(self, context):
207         layout = self.layout
208
209         layout.operator_context = 'INVOKE_REGION_WIN'
210         layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
211         layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
212         layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
213         layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
214         layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
215         layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
216         layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
217         layout.separator()
218         layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
219         layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
220         layout.operator("mesh.primitive_torus_add", icon='MESH_TORUS', text="Torus")
221
222
223 class INFO_MT_curve_add(Menu):
224     bl_idname = "INFO_MT_curve_add"
225     bl_label = "Curve"
226
227     def draw(self, context):
228         layout = self.layout
229
230         layout.operator_context = 'INVOKE_REGION_WIN'
231         layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
232         layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
233         layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
234         layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
235         layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
236
237
238 class INFO_MT_surface_add(Menu):
239     bl_idname = "INFO_MT_surface_add"
240     bl_label = "Surface"
241
242     def draw(self, context):
243         layout = self.layout
244
245         layout.operator_context = 'INVOKE_REGION_WIN'
246         layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
247         layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
248         layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
249         layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
250         layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
251         layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
252
253
254 class INFO_MT_edit_curve_add(Menu):
255     bl_idname = "INFO_MT_edit_curve_add"
256     bl_label = "Add"
257
258     def draw(self, context):
259         is_surf = context.active_object.type == 'SURFACE'
260
261         layout = self.layout
262         layout.operator_context = 'EXEC_REGION_WIN'
263
264         if is_surf:
265             INFO_MT_surface_add.draw(self, context)
266         else:
267             INFO_MT_curve_add.draw(self, context)
268
269
270 class INFO_MT_armature_add(Menu):
271     bl_idname = "INFO_MT_armature_add"
272     bl_label = "Armature"
273
274     def draw(self, context):
275         layout = self.layout
276
277         layout.operator_context = 'EXEC_REGION_WIN'
278         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
279
280
281 class INFO_MT_add(Menu):
282     bl_label = "Add"
283
284     def draw(self, context):
285         layout = self.layout
286
287         # note, don't use 'EXEC_SCREEN' or operators wont get the 'v3d' context.
288
289         # Note: was EXEC_AREA, but this context does not have the 'rv3d', which prevents
290         #       "align_view" to work on first call (see [#32719]).
291         layout.operator_context = 'EXEC_REGION_WIN'
292
293         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
294         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
295
296         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
297         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
298         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
299         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
300         layout.operator_context = 'INVOKE_REGION_WIN'
301         layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
302         layout.operator_context = 'EXEC_REGION_WIN'
303         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
304         layout.separator()
305
306         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
307         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
308         layout.operator_menu_enum("object.empty_add", "type", text="Empty", icon='OUTLINER_OB_EMPTY')
309         layout.separator()
310
311         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
312         layout.separator()
313
314         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
315         layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
316         layout.separator()
317
318         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
319         layout.separator()
320
321         if len(bpy.data.groups) > 10:
322             layout.operator_context = 'INVOKE_REGION_WIN'
323             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
324         else:
325             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
326
327
328 class INFO_MT_game(Menu):
329     bl_label = "Game"
330
331     def draw(self, context):
332         layout = self.layout
333
334         gs = context.scene.game_settings
335
336         layout.operator("view3d.game_start")
337
338         layout.separator()
339
340         layout.prop(gs, "show_debug_properties")
341         layout.prop(gs, "show_framerate_profile")
342         layout.prop(gs, "show_physics_visualization")
343         layout.prop(gs, "use_deprecation_warnings")
344         layout.prop(gs, "use_animation_record")
345         layout.separator()
346         layout.prop(gs, "use_auto_start")
347
348
349 class INFO_MT_render(Menu):
350     bl_label = "Render"
351
352     def draw(self, context):
353         layout = self.layout
354
355         layout.operator("render.render", text="Render Image", icon='RENDER_STILL')
356         layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION').animation = True
357
358         layout.separator()
359
360         layout.operator("render.opengl", text="OpenGL Render Image")
361         layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
362
363         layout.separator()
364
365         layout.operator("render.view_show")
366         layout.operator("render.play_rendered_anim")
367
368
369 class INFO_MT_window(Menu):
370     bl_label = "Window"
371
372     def draw(self, context):
373         import sys
374
375         layout = self.layout
376
377         layout.operator("wm.window_duplicate")
378         layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
379
380         layout.separator()
381
382         layout.operator("screen.screenshot").full = True
383         layout.operator("screen.screencast").full = True
384
385         if sys.platform[:3] == "win":
386             layout.separator()
387             layout.operator("wm.console_toggle", icon='CONSOLE')
388
389
390 class INFO_MT_help(Menu):
391     bl_label = "Help"
392
393     def draw(self, context):
394         layout = self.layout
395
396         layout.operator("wm.url_open", text="Manual", icon='HELP').url = "http://wiki.blender.org/index.php/Doc:2.6/Manual"
397         layout.operator("wm.url_open", text="Release Log", icon='URL').url = "http://www.blender.org/development/release-logs/blender-269"
398         layout.separator()
399
400         layout.operator("wm.url_open", text="Blender Website", icon='URL').url = "http://www.blender.org"
401         layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = "http://www.blender.org/e-shop"
402         layout.operator("wm.url_open", text="Developer Community", icon='URL').url = "http://www.blender.org/community/get-involved"
403         layout.operator("wm.url_open", text="User Community", icon='URL').url = "http://www.blender.org/community/user-community"
404         layout.separator()
405         layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = "http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse"
406         layout.separator()
407
408         layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix
409         layout.operator("wm.operator_cheat_sheet", icon='TEXT')
410         layout.operator("wm.sysinfo", icon='TEXT')
411         layout.separator()
412         layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP')
413         layout.operator("logic.texface_convert", text="TexFace to Material Convert", icon='GAME')
414         layout.separator()
415
416         layout.operator("wm.splash", icon='BLENDER')
417
418 if __name__ == "__main__":  # only for live edit.
419     bpy.utils.register_module(__name__)