* Fixing Link to Release Logs.
[blender.git] / release / scripts / 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         wm = context.window_manager
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
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         layout.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
72 class INFO_MT_file(bpy.types.Menu):
73     bl_label = "File"
74
75     def draw(self, context):
76         layout = self.layout
77
78         layout.operator_context = 'EXEC_AREA'
79         layout.operator("wm.read_homefile", text="New", icon='NEW')
80         layout.operator_context = 'INVOKE_AREA'
81         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
82         layout.menu("INFO_MT_file_open_recent")
83         layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
84         layout.operator("wm.recover_auto_save", text="Recover Auto Save...")
85
86         layout.separator()
87
88         layout.operator_context = 'INVOKE_AREA'
89         layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK').check_existing = False
90         layout.operator_context = 'INVOKE_AREA'
91         layout.operator("wm.save_as_mainfile", text="Save As...")
92         layout.operator_context = 'INVOKE_AREA'
93         layout.operator("wm.save_as_mainfile", text="Save Copy...").copy = True
94
95         layout.separator()
96
97         layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
98
99         layout.operator_context = 'EXEC_AREA'
100         layout.operator("wm.read_homefile", text="Load Factory Settings").factory = True
101
102         layout.separator()
103
104         layout.operator_context = 'INVOKE_AREA'
105         layout.operator("wm.link_append", text="Link")
106         props = layout.operator("wm.link_append", text="Append")
107         props.link = False
108         props.instance_groups = False
109
110         layout.separator()
111
112         layout.menu("INFO_MT_file_import")
113         layout.menu("INFO_MT_file_export")
114
115         layout.separator()
116
117         layout.menu("INFO_MT_file_external_data")
118
119         layout.separator()
120
121         layout.operator_context = 'EXEC_AREA'
122         layout.operator("wm.exit_blender", text="Quit", icon='QUIT')
123
124
125 class INFO_MT_file_import(bpy.types.Menu):
126     bl_idname = "INFO_MT_file_import"
127     bl_label = "Import"
128
129     def draw(self, context):
130         if hasattr(bpy.types, "WM_OT_collada_import"):
131             self.layout.operator("wm.collada_import", text="COLLADA (.dae)")
132
133
134 class INFO_MT_file_export(bpy.types.Menu):
135     bl_idname = "INFO_MT_file_export"
136     bl_label = "Export"
137
138     def draw(self, context):
139         if hasattr(bpy.types, "WM_OT_collada_export"):
140             self.layout.operator("wm.collada_export", text="COLLADA (.dae)")
141
142
143 class INFO_MT_file_external_data(bpy.types.Menu):
144     bl_label = "External Data"
145
146     def draw(self, context):
147         layout = self.layout
148
149         layout.operator("file.pack_all", text="Pack into .blend file")
150         layout.operator("file.unpack_all", text="Unpack into Files")
151
152         layout.separator()
153
154         layout.operator("file.make_paths_relative")
155         layout.operator("file.make_paths_absolute")
156         layout.operator("file.report_missing_files")
157         layout.operator("file.find_missing_files")
158
159
160 class INFO_MT_mesh_add(bpy.types.Menu):
161     bl_idname = "INFO_MT_mesh_add"
162     bl_label = "Mesh"
163
164     def draw(self, context):
165         layout = self.layout
166         layout.operator_context = 'INVOKE_REGION_WIN'
167         layout.operator("mesh.primitive_plane_add", icon='MESH_PLANE', text="Plane")
168         layout.operator("mesh.primitive_cube_add", icon='MESH_CUBE', text="Cube")
169         layout.operator("mesh.primitive_circle_add", icon='MESH_CIRCLE', text="Circle")
170         layout.operator("mesh.primitive_uv_sphere_add", icon='MESH_UVSPHERE', text="UV Sphere")
171         layout.operator("mesh.primitive_ico_sphere_add", icon='MESH_ICOSPHERE', text="Icosphere")
172         layout.operator("mesh.primitive_cylinder_add", icon='MESH_CYLINDER', text="Cylinder")
173         layout.operator("mesh.primitive_cone_add", icon='MESH_CONE', text="Cone")
174         layout.separator()
175         layout.operator("mesh.primitive_grid_add", icon='MESH_GRID', text="Grid")
176         layout.operator("mesh.primitive_monkey_add", icon='MESH_MONKEY', text="Monkey")
177
178
179 class INFO_MT_curve_add(bpy.types.Menu):
180     bl_idname = "INFO_MT_curve_add"
181     bl_label = "Curve"
182
183     def draw(self, context):
184         layout = self.layout
185         layout.operator_context = 'INVOKE_REGION_WIN'
186         layout.operator("curve.primitive_bezier_curve_add", icon='CURVE_BEZCURVE', text="Bezier")
187         layout.operator("curve.primitive_bezier_circle_add", icon='CURVE_BEZCIRCLE', text="Circle")
188         layout.operator("curve.primitive_nurbs_curve_add", icon='CURVE_NCURVE', text="Nurbs Curve")
189         layout.operator("curve.primitive_nurbs_circle_add", icon='CURVE_NCIRCLE', text="Nurbs Circle")
190         layout.operator("curve.primitive_nurbs_path_add", icon='CURVE_PATH', text="Path")
191
192
193 class INFO_MT_surface_add(bpy.types.Menu):
194     bl_idname = "INFO_MT_surface_add"
195     bl_label = "Surface"
196
197     def draw(self, context):
198         layout = self.layout
199         layout.operator_context = 'INVOKE_REGION_WIN'
200         layout.operator("surface.primitive_nurbs_surface_curve_add", icon='SURFACE_NCURVE', text="NURBS Curve")
201         layout.operator("surface.primitive_nurbs_surface_circle_add", icon='SURFACE_NCIRCLE', text="NURBS Circle")
202         layout.operator("surface.primitive_nurbs_surface_surface_add", icon='SURFACE_NSURFACE', text="NURBS Surface")
203         layout.operator("surface.primitive_nurbs_surface_cylinder_add", icon='SURFACE_NCYLINDER', text="NURBS Cylinder")
204         layout.operator("surface.primitive_nurbs_surface_sphere_add", icon='SURFACE_NSPHERE', text="NURBS Sphere")
205         layout.operator("surface.primitive_nurbs_surface_torus_add", icon='SURFACE_NTORUS', text="NURBS Torus")
206
207
208 class INFO_MT_armature_add(bpy.types.Menu):
209     bl_idname = "INFO_MT_armature_add"
210     bl_label = "Armature"
211
212     def draw(self, context):
213         layout = self.layout
214         layout.operator_context = 'INVOKE_REGION_WIN'
215         layout.operator("object.armature_add", text="Single Bone", icon='BONE_DATA')
216
217
218 class INFO_MT_add(bpy.types.Menu):
219     bl_label = "Add"
220
221     def draw(self, context):
222         layout = self.layout
223
224         layout.operator_context = 'EXEC_SCREEN'
225
226         #layout.operator_menu_enum("object.mesh_add", "type", text="Mesh", icon='OUTLINER_OB_MESH')
227         layout.menu("INFO_MT_mesh_add", icon='OUTLINER_OB_MESH')
228
229         #layout.operator_menu_enum("object.curve_add", "type", text="Curve", icon='OUTLINER_OB_CURVE')
230         layout.menu("INFO_MT_curve_add", icon='OUTLINER_OB_CURVE')
231         #layout.operator_menu_enum("object.surface_add", "type", text="Surface", icon='OUTLINER_OB_SURFACE')
232         layout.menu("INFO_MT_surface_add", icon='OUTLINER_OB_SURFACE')
233         layout.operator_menu_enum("object.metaball_add", "type", text="Metaball", icon='OUTLINER_OB_META')
234         layout.operator("object.text_add", text="Text", icon='OUTLINER_OB_FONT')
235         layout.separator()
236
237         layout.operator_context = 'INVOKE_REGION_WIN'
238         layout.menu("INFO_MT_armature_add", icon='OUTLINER_OB_ARMATURE')
239         layout.operator("object.add", text="Lattice", icon='OUTLINER_OB_LATTICE').type = 'LATTICE'
240         layout.operator("object.add", text="Empty", icon='OUTLINER_OB_EMPTY').type = 'EMPTY'
241         layout.separator()
242
243         layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
244         layout.operator_context = 'EXEC_SCREEN'
245         layout.operator_menu_enum("object.lamp_add", "type", text="Lamp", icon='OUTLINER_OB_LAMP')
246         layout.separator()
247
248         layout.operator_menu_enum("object.effector_add", "type", text="Force Field", icon='OUTLINER_OB_EMPTY')
249         layout.separator()
250
251         if(len(bpy.data.groups) > 10):
252             layout.operator_context = 'INVOKE_DEFAULT'
253             layout.operator("object.group_instance_add", text="Group Instance...", icon='OUTLINER_OB_EMPTY')
254         else:
255             layout.operator_menu_enum("object.group_instance_add", "group", text="Group Instance", icon='OUTLINER_OB_EMPTY')
256
257
258 class INFO_MT_game(bpy.types.Menu):
259     bl_label = "Game"
260
261     def draw(self, context):
262         layout = self.layout
263
264         gs = context.scene.game_settings
265
266         layout.operator("view3d.game_start")
267
268         layout.separator()
269
270         layout.prop(gs, "show_debug_properties")
271         layout.prop(gs, "show_framerate_profile")
272         layout.prop(gs, "show_physics_visualization")
273         layout.prop(gs, "use_deprecation_warnings")
274         layout.prop(gs, "use_animation_record")
275         layout.separator()
276         layout.prop(gs, "use_auto_start")
277
278
279 class INFO_MT_render(bpy.types.Menu):
280     bl_label = "Render"
281
282     def draw(self, context):
283         layout = self.layout
284
285         # rd = context.scene.render
286
287         layout.operator("render.render", text="Render Image", icon='RENDER_STILL')
288         layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION').animation = True
289
290         layout.separator()
291
292         layout.operator("render.opengl", text="OpenGL Render Image")
293         layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
294
295         layout.separator()
296
297         layout.operator("render.view_show")
298         layout.operator("render.play_rendered_anim")
299
300
301 class INFO_MT_help(bpy.types.Menu):
302     bl_label = "Help"
303
304     def draw(self, context):
305         layout = self.layout
306
307         layout.operator("wm.url_open", text="Manual", icon='HELP').url = 'http://wiki.blender.org/index.php/Doc:Manual'
308         layout.operator("wm.url_open", text="Release Log", icon='URL').url = 'http://www.blender.org/development/release-logs/blender-254-beta/'
309
310         layout.separator()
311
312         layout.operator("wm.url_open", text="Blender Website", icon='URL').url = 'http://www.blender.org/'
313         layout.operator("wm.url_open", text="Blender e-Shop", icon='URL').url = 'http://www.blender.org/e-shop'
314         layout.operator("wm.url_open", text="Developer Community", icon='URL').url = 'http://www.blender.org/community/get-involved/'
315         layout.operator("wm.url_open", text="User Community", icon='URL').url = 'http://www.blender.org/community/user-community/'
316         layout.separator()
317         layout.operator("wm.url_open", text="Report a Bug", icon='URL').url = 'http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse'
318         layout.separator()
319         layout.operator("wm.url_open", text="Python API Reference", icon='URL').url = "http://www.blender.org/documentation/blender_python_api_%s/contents.html" % "_".join(str(v) for v in bpy.app.version)
320         layout.operator("help.operator_cheat_sheet", icon='TEXT')
321         layout.separator()
322         layout.operator("anim.update_data_paths", text="FCurve/Driver 2.54 fix", icon='HELP')
323         layout.separator()
324         layout.operator("wm.splash")
325
326
327 # Help operators
328
329
330 class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
331     bl_idname = "help.operator_cheat_sheet"
332     bl_label = "Operator Cheat Sheet"
333
334     def execute(self, context):
335         op_strings = []
336         tot = 0
337         for op_module_name in dir(bpy.ops):
338             op_module = getattr(bpy.ops, op_module_name)
339             for op_submodule_name in dir(op_module):
340                 op = getattr(op_module, op_submodule_name)
341                 text = repr(op)
342                 if text.startswith('bpy.ops.'):
343                     op_strings.append(text)
344                     tot += 1
345
346             op_strings.append('')
347
348         textblock = bpy.data.texts.new("OperatorList.txt")
349         textblock.write('# %d Operators\n\n' % tot)
350         textblock.write('\n'.join(op_strings))
351         self.report({'INFO'}, "See OperatorList.txt textblock")
352         return {'FINISHED'}
353
354
355 def register():
356     pass
357
358
359 def unregister():
360     pass
361
362 if __name__ == "__main__":
363     register()