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