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