eba2581252a551d4e4a4cd73e1f62a17c8753134
[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
22
23 class INFO_HT_header(bpy.types.Header):
24     bl_space_type = 'INFO'
25
26     def draw(self, context):
27         layout = self.layout
28
29         window = context.window
30         scene = context.scene
31         rd = scene.render
32
33         row = layout.row(align=True)
34         row.template_header()
35
36         if context.area.show_menus:
37             sub = row.row(align=True)
38             sub.menu("INFO_MT_file")
39             sub.menu("INFO_MT_add")
40             if rd.use_game_engine:
41                 sub.menu("INFO_MT_game")
42             else:
43                 sub.menu("INFO_MT_render")
44             sub.menu("INFO_MT_help")
45
46         if window.screen.show_fullscreen:
47             layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
48             layout.separator()
49         else:
50             layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
51             layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
52
53         layout.separator()
54
55         if rd.has_multiple_engines:
56             layout.prop(rd, "engine", text="")
57
58         layout.separator()
59
60         layout.template_running_jobs()
61
62         layout.template_reports_banner()
63
64         row = layout.row(align=True)
65         row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
66         row.label(text=scene.statistics())
67
68         # XXX: this should be right-aligned to the RHS of the region
69         layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER', text="")
70
71         # XXX: BEFORE RELEASE, MOVE FILE MENU OUT OF INFO!!!
72         """
73         sinfo = context.space_data
74         row = layout.row(align=True)
75         row.prop(sinfo, "show_report_debug", text="Debug")
76         row.prop(sinfo, "show_report_info", text="Info")
77         row.prop(sinfo, "show_report_operator", text="Operators")
78         row.prop(sinfo, "show_report_warning", text="Warnings")
79         row.prop(sinfo, "show_report_error", text="Errors")
80
81         row = layout.row()
82         row.enabled = sinfo.show_report_operator
83         row.operator("info.report_replay")
84
85         row.menu("INFO_MT_report")
86         """
87
88
89 class INFO_MT_report(bpy.types.Menu):
90     bl_label = "Report"
91
92     def draw(self, context):
93         layout = self.layout
94         layout.column()
95         layout.operator("console.select_all_toggle")
96         layout.operator("console.select_border")
97         layout.operator("console.report_delete")
98         layout.operator("console.report_copy")
99
100
101 class INFO_MT_file(bpy.types.Menu):
102     bl_label = "File"
103
104     def draw(self, context):
105         layout = self.layout
106
107         layout.operator_context = 'EXEC_AREA'
108         layout.operator("wm.read_homefile", text="New", icon='NEW')
109         layout.operator_context = 'INVOKE_AREA'
110         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
111         layout.menu("INFO_MT_file_open_recent")
112         layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
113         layout.operator("wm.recover_auto_save", text="Recover Auto Save...")
114
115         layout.separator()
116
117         layout.operator_context = 'INVOKE_AREA'
118         layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK').check_existing = False
119         layout.operator_context = 'INVOKE_AREA'
120         layout.operator("wm.save_as_mainfile", text="Save As...")
121         layout.operator_context = 'INVOKE_AREA'
122         layout.operator("wm.save_as_mainfile", text="Save Copy...").copy = True
123
124         layout.separator()
125
126         layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
127
128         layout.operator_context = 'EXEC_AREA'
129         layout.operator("wm.save_homefile")
130         layout.operator("wm.read_factory_settings")
131
132         layout.separator()
133
134         layout.operator_context = 'INVOKE_AREA'
135         layout.operator("wm.link_append", text="Link")
136         props = layout.operator("wm.link_append", text="Append")
137         props.link = False
138         props.instance_groups = False
139
140         layout.separator()
141
142         layout.menu("INFO_MT_file_import")
143         layout.menu("INFO_MT_file_export")
144
145         layout.separator()
146
147         layout.menu("INFO_MT_file_external_data")
148
149         layout.separator()
150
151         layout.operator_context = 'EXEC_AREA'
152         layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
153
154
155 class INFO_MT_file_import(bpy.types.Menu):
156     bl_idname = "INFO_MT_file_import"
157     bl_label = "Import"
158
159     def draw(self, context):
160         if hasattr(bpy.types, "WM_OT_collada_import"):
161             self.layout.operator("wm.collada_import", text="COLLADA (.dae)")
162
163
164 class INFO_MT_file_export(bpy.types.Menu):
165     bl_idname = "INFO_MT_file_export"
166     bl_label = "Export"
167
168     def draw(self, context):
169         if hasattr(bpy.types, "WM_OT_collada_export"):
170             self.layout.operator("wm.collada_export", text="COLLADA (.dae)")
171
172
173 class INFO_MT_file_external_data(bpy.types.Menu):
174     bl_label = "External Data"
175
176     def draw(self, context):
177         layout = self.layout
178
179         layout.operator("file.pack_all", text="Pack into .blend file")
180         layout.operator("file.unpack_all", text="Unpack into Files")
181
182         layout.separator()
183
184         layout.operator("file.make_paths_relative")
185         layout.operator("file.make_paths_absolute")
186         layout.operator("file.report_missing_files")
187         layout.operator("file.find_missing_files")
188
189
190 class INFO_MT_mesh_add(bpy.types.Menu):
191     bl_idname = "INFO_MT_mesh_add"
192     bl_label = "Mesh"
193
194     def draw(self, context):
195         layout = self.layout
196         layout.operator_context = 'INVOKE_REGION_WIN'
197         layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
198         layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
199         layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
200         layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
201         layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
202         layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
203         layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
204         layout.separator()
205         layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
206         layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
207         layout.operator("mesh.primitive_torus_add", text="Torus", icon='MESH_TORUS')
208
209
210 class INFO_MT_curve_add(bpy.types.Menu):
211     bl_idname = "INFO_MT_curve_add"
212     bl_label = "Curve"
213
214     def draw(self, context):
215         layout = self.layout
216         layout.operator_context = 'INVOKE_REGION_WIN'
217         layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
218         layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
219         layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
220         layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
221         layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
222
223
224 class INFO_MT_edit_curve_add(bpy.types.Menu):
225     bl_idname = "INFO_MT_edit_curve_add"
226     bl_label = "Add"
227
228     def draw(self, context):
229         is_surf = context.active_object.type == 'SURFACE'
230
231         layout = self.layout
232         layout.operator_context = 'INVOKE_REGION_WIN'
233
234         if is_surf:
235             INFO_MT_surface_add.draw(self, context)
236         else:
237             INFO_MT_curve_add.draw(self, context)
238
239
240 class INFO_MT_surface_add(bpy.types.Menu):
241     bl_idname = "INFO_MT_surface_add"
242     bl_label = "Surface"
243
244     def draw(self, context):
245         layout = self.layout
246         layout.operator_context = 'INVOKE_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_armature_add(bpy.types.Menu):
256     bl_idname = "INFO_MT_armature_add"
257     bl_label = "Armature"
258
259     def draw(self, context):
260         layout = self.layout
261         layout.operator_context = 'INVOKE_REGION_WIN'
262         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
263
264
265 class INFO_MT_add(bpy.types.Menu):
266     bl_label = "Add"
267
268     def draw(self, context):
269         layout = self.layout
270
271         layout.operator_context = 'EXEC_SCREEN'
272
273         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
274         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
275
276         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
277         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
278         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
279         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
280         layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
281         layout.operator_context = 'INVOKE_REGION_WIN'
282         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
283         layout.separator()
284
285         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
286         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
287         layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY'
288         layout.separator()
289
290         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
291         layout.operator_context = 'EXEC_SCREEN'
292         layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
293         layout.separator()
294
295         layout.operator("object.speaker_add", text="Speaker", icon='SPEAKER')
296         layout.separator()
297
298         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
299         layout.separator()
300
301         if(len(bpy.data.groups) > 10):
302             layout.operator_context = 'INVOKE_DEFAULT'
303             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
304         else:
305             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
306
307
308 class INFO_MT_game(bpy.types.Menu):
309     bl_label = "Game"
310
311     def draw(self, context):
312         layout = self.layout
313
314         gs = context.scene.game_settings
315
316         layout.operator("view3d.game_start")
317
318         layout.separator()
319
320         layout.prop(gs, "show_debug_properties")
321         layout.prop(gs, "show_framerate_profile")
322         layout.prop(gs, "show_physics_visualization")
323         layout.prop(gs, "use_deprecation_warnings")
324         layout.prop(gs, "use_animation_record")
325         layout.separator()
326         layout.prop(gs, "use_auto_start")
327
328
329 class INFO_MT_render(bpy.types.Menu):
330     bl_label = "Render"
331
332     def draw(self, context):
333         layout = self.layout
334
335         layout.operator("render.render", text="Render Image", icon='RENDER_STILL')
336         layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION').animation = True
337
338         layout.separator()
339
340         layout.operator("render.opengl", text="OpenGL Render Image")
341         layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
342
343         layout.separator()
344
345         layout.operator("render.view_show")
346         layout.operator("render.play_rendered_anim")
347
348
349 class INFO_MT_help(bpy.types.Menu):
350     bl_label = "Help"
351
352     def draw(self, context):
353         import sys
354
355         layout = self.layout
356
357         layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
358         layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-258/'
359
360         layout.separator()
361
362         layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/'
363         layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = 'http://www.blender.org/e-shop'
364         layout.operator("wm.url_open", text="Developer Community", icon='URL').url = 'http://www.blender.org/community/get-involved/'
365         layout.operator("wm.url_open", text="User Community", icon='URL').url = 'http://www.blender.org/community/user-community/'
366         layout.separator()
367         layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = 'http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse'
368         layout.separator()
369
370         layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = bpy.types.WM_OT_doc_view._prefix
371         layout.operator("help.operator_cheat_sheet", icon='TEXT')
372         layout.operator("wm.sysinfo", icon='TEXT')
373         layout.separator()
374         if sys.platform[:3] == "win":
375             layout.operator("wm.console_toggle", icon='CONSOLE')
376             layout.separator()
377         layout.operator("anim.update_data_paths", text="FCurve/Driver Version fix", icon='HELP')
378         layout.separator()
379         layout.operator("wm.splash", icon='BLENDER')
380
381
382 # Help operators
383
384
385 class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
386     bl_idname = "help.operator_cheat_sheet"
387     bl_label = "Operator Cheat Sheet"
388
389     def execute(self, context):
390         op_strings = []
391         tot = 0
392         for op_module_name in dir(bpy.ops):
393             op_module = getattr(bpy.ops, op_module_name)
394             for op_submodule_name in dir(op_module):
395                 op = getattr(op_module, op_submodule_name)
396                 text = repr(op)
397                 if text.split("\n")[-1].startswith('bpy.ops.'):
398                     op_strings.append(text)
399                     tot += 1
400
401             op_strings.append('')
402
403         textblock = bpy.data.texts.new("OperatorList.txt")
404         textblock.write('# %d Operators\n\n' % tot)
405         textblock.write('\n'.join(op_strings))
406         self.report({'INFO'}, "See OperatorList.txt textblock")
407         return {'FINISHED'}
408
409 if __name__ == "__main__":  # only for live edit.
410     bpy.utils.register_module(__name__)