Integrated Freestyle to rendering pipeline
[blender.git] / release / ui / space_info.py
1
2 import bpy
3
4 class INFO_HT_header(bpy.types.Header):
5         __space_type__ = 'INFO'
6
7         def draw(self, context):
8                 layout = self.layout
9                 
10                 st = context.space_data
11                 scene = context.scene
12                 rd = scene.render_data
13
14                 row = layout.row(align=True)
15                 row.template_header()
16
17                 if context.area.show_menus:
18                         sub = row.row(align=True)
19                         sub.itemM("INFO_MT_file")
20                         sub.itemM("INFO_MT_add")
21                         if rd.use_game_engine:
22                                 sub.itemM("INFO_MT_game")
23                         else:
24                                 sub.itemM("INFO_MT_render")
25                         sub.itemM("INFO_MT_help")
26
27                 layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
28                 layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
29
30                 if rd.multiple_engines:
31                         layout.itemR(rd, "engine", text="")
32
33                 layout.itemS()
34
35                 layout.template_operator_search()
36                 layout.template_running_jobs()
37
38                 layout.itemL(text=scene.statistics())
39                         
40 class INFO_MT_file(bpy.types.Menu):
41         __space_type__ = 'INFO'
42         __label__ = "File"
43
44         def draw(self, context):
45                 layout = self.layout
46
47                 layout.operator_context = "EXEC_AREA"
48                 layout.itemO("wm.read_homefile", text="New")
49                 layout.operator_context = "INVOKE_AREA"
50                 layout.itemO("wm.open_mainfile", text="Open...")
51                 layout.item_menu_enumO("wm.open_recentfile", "file", text="Open Recent")
52                 layout.itemO("wm.recover_last_session")
53
54                 layout.itemS()
55
56                 layout.operator_context = "EXEC_AREA"
57                 layout.itemO("wm.save_mainfile", text="Save")
58                 layout.operator_context = "INVOKE_AREA"
59                 layout.itemO("wm.save_as_mainfile", text="Save As...")
60                 layout.itemO("screen.userpref_show", text="User Preferences...")
61
62                 layout.itemS()
63                 layout.operator_context = "INVOKE_AREA"
64                 layout.itemO("wm.link_append", text="Link")
65                 layout.item_booleanO("wm.link_append", "link", False, text="Append")
66                 layout.itemS()
67
68                 layout.itemM("INFO_MT_file_import")
69                 layout.itemM("INFO_MT_file_export")
70
71                 layout.itemS()
72
73                 layout.itemM("INFO_MT_file_external_data")
74
75                 layout.itemS()
76
77                 layout.operator_context = "EXEC_AREA"
78                 layout.itemO("wm.exit_blender", text="Quit")
79
80 class INFO_MT_file_import(bpy.types.Menu):
81         __space_type__ = 'INFO'
82         __label__ = "Import"
83
84         def draw(self, context):
85                 layout = self.layout
86                 
87                 layout.itemL(text="Nothing yet")
88
89 class INFO_MT_file_export(bpy.types.Menu):
90         __space_type__ = 'INFO'
91         __label__ = "Export"
92
93         def draw(self, context):
94                 layout = self.layout
95
96                 layout.itemO("export.ply", text="PLY")
97
98 class INFO_MT_file_external_data(bpy.types.Menu):
99         __space_type__ = 'INFO'
100         __label__ = "External Data"
101
102         def draw(self, context):
103                 layout = self.layout
104
105                 layout.itemO("file.pack_all", text="Pack into .blend file")
106                 layout.itemO("file.unpack_all", text="Unpack into Files...")
107
108                 layout.itemS()
109
110                 layout.itemO("file.make_paths_relative")
111                 layout.itemO("file.make_paths_absolute")
112                 layout.itemO("file.report_missing_files")
113                 layout.itemO("file.find_missing_files")
114
115 class INFO_MT_add(bpy.types.Menu):
116         __space_type__ = 'INFO'
117         __label__ = "Add"
118
119         def draw(self, context):
120                 layout = self.layout
121
122                 layout.operator_context = "EXEC_SCREEN"
123
124                 layout.item_menu_enumO("object.mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH')
125                 layout.item_menu_enumO("object.curve_add", "type", text="Curve", icon='ICON_OUTLINER_OB_CURVE')
126                 layout.item_menu_enumO("object.surface_add", "type", text="Surface", icon='ICON_OUTLINER_OB_SURFACE')
127                 layout.item_menu_enumO("object.metaball_add", "type", 'META', icon='ICON_OUTLINER_OB_META')
128                 layout.itemO("object.text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
129
130                 layout.itemS()
131
132                 layout.itemO("object.armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
133                 layout.item_enumO("object.add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
134                 layout.item_enumO("object.add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY')
135
136                 layout.itemS()
137
138                 layout.item_enumO("object.add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
139                 layout.item_enumO("object.add", "type", 'LAMP', icon='ICON_OUTLINER_OB_LAMP')
140
141 class INFO_MT_game(bpy.types.Menu):
142         __space_type__ = 'INFO'
143         __label__ = "Game"
144
145         def draw(self, context):
146                 layout = self.layout
147
148                 gs = context.scene.game_data
149
150                 layout.itemO("view3d.game_start")
151
152                 layout.itemS()
153
154                 layout.itemR(gs, "show_debug_properties")
155                 layout.itemR(gs, "show_framerate_profile")
156                 layout.itemR(gs, "show_physics_visualization")
157                 layout.itemR(gs, "deprecation_warnings")
158
159 class INFO_MT_render(bpy.types.Menu):
160         __space_type__ = 'INFO'
161         __label__ = "Render"
162
163         def draw(self, context):
164                 layout = self.layout
165                 
166                 rd = context.scene.render_data
167
168                 layout.itemO("screen.render", text="Render Image")
169                 layout.item_booleanO("screen.render", "animation", True, text="Render Animation")
170
171                 layout.itemS()
172
173                 layout.itemO("screen.render_view_show")
174
175 class INFO_MT_help(bpy.types.Menu):
176         __space_type__ = 'INFO'
177         __label__ = "Help"
178
179         def draw(self, context):
180                 layout = self.layout
181
182                 layout.itemO("help.manual")
183                 layout.itemO("help.release_logs")
184
185                 layout.itemS()
186
187                 layout.itemO("help.blender_website")
188                 layout.itemO("help.blender_eshop")
189                 layout.itemO("help.developer_community")
190                 layout.itemO("help.user_community")
191                 layout.itemS()
192                 layout.itemO("help.operator_cheat_sheet")
193                 
194
195 bpy.types.register(INFO_HT_header)
196 bpy.types.register(INFO_MT_file)
197 bpy.types.register(INFO_MT_file_import)
198 bpy.types.register(INFO_MT_file_export)
199 bpy.types.register(INFO_MT_file_external_data)
200 bpy.types.register(INFO_MT_add)
201 bpy.types.register(INFO_MT_game)
202 bpy.types.register(INFO_MT_render)
203 bpy.types.register(INFO_MT_help)
204
205 # Help operators
206
207 import bpy_ops # XXX - should not need to do this
208 del bpy_ops
209
210 class HelpOperator(bpy.types.Operator):
211         def execute(self, context):
212                 try: import webbrowser
213                 except: webbrowser = None
214
215                 if webbrowser:
216                         webbrowser.open(self.__URL__)
217                 else:
218                         raise Exception("Operator requires a full Python installation")
219
220                 return ('FINISHED',)
221
222 class HELP_OT_manual(HelpOperator):
223         __idname__ = "help.manual"
224         __label__ = "Manual"
225         __URL__ = 'http://wiki.blender.org/index.php/Manual'
226
227 class HELP_OT_release_logs(HelpOperator):
228         __idname__ = "help.release_logs"
229         __label__ = "Release Logs"
230         __URL__ = 'http://www.blender.org/development/release-logs/'
231
232 class HELP_OT_blender_website(HelpOperator):
233         __idname__ = "help.blender_website"
234         __label__ = "Blender Website"
235         __URL__ = 'http://www.blender.org/'
236
237 class HELP_OT_blender_eshop(HelpOperator):
238         __idname__ = "help.blender_eshop"
239         __label__ = "Blender e-Shop"
240         __URL__ = 'http://www.blender3d.org/e-shop'
241
242 class HELP_OT_developer_community(HelpOperator):
243         __idname__ = "help.developer_community"
244         __label__ = "Developer Community"
245         __URL__ = 'http://www.blender.org/community/get-involved/'
246
247 class HELP_OT_user_community(HelpOperator):
248         __idname__ = "help.user_community"
249         __label__ = "User Community"
250         __URL__ = 'http://www.blender.org/community/user-community/'
251
252 class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
253         __idname__ = "help.operator_cheat_sheet"
254         __label__ = "Operator Cheet Sheet (new textblock)"
255         def execute(self, context):
256                 op_strings = []
257                 tot = 0
258                 for op_module_name in dir(bpy.ops):
259                         op_module = getattr(bpy.ops, op_module_name)
260                         for op_submodule_name in dir(op_module):
261                                 op = getattr(op_module, op_submodule_name)
262                                 text = repr(op)
263                                 if text.startswith('bpy.ops.'):
264                                         op_strings.append(text)
265                                         tot += 1
266                         
267                         op_strings.append('')
268                 
269                 bpy.ops.text.new() # XXX - assumes new text is always at the end!
270                 textblock = bpy.data.texts[-1]
271                 textblock.write('# %d Operators\n\n' % tot)
272                 textblock.write('\n'.join(op_strings))
273                 textblock.name = "OperatorList.txt"
274                 print("See OperatorList.txt textblock")
275                 return ('FINISHED',)
276
277
278 bpy.ops.add(HELP_OT_manual)
279 bpy.ops.add(HELP_OT_release_logs)
280 bpy.ops.add(HELP_OT_blender_website)
281 bpy.ops.add(HELP_OT_blender_eshop)
282 bpy.ops.add(HELP_OT_developer_community)
283 bpy.ops.add(HELP_OT_user_community)
284 bpy.ops.add(HELP_OT_operator_cheat_sheet)
285