Manual merge of soc-2009-kazanbas branch:
[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.itemO("import.3ds", text="3DS")
88                 layout.itemO("import.obj", text="OBJ")
89
90
91 class INFO_MT_file_export(bpy.types.Menu):
92         __space_type__ = 'INFO'
93         __label__ = "Export"
94
95         def draw(self, context):
96                 layout = self.layout
97
98                 layout.itemO("export.3ds", text="3DS")
99                 layout.itemO("export.fbx", text="FBX")
100                 layout.itemO("export.obj", text="OBJ")
101                 layout.itemO("export.ply", text="PLY")
102                 layout.itemO("export.x3d", text="X3D")
103
104
105 class INFO_MT_file_external_data(bpy.types.Menu):
106         __space_type__ = 'INFO'
107         __label__ = "External Data"
108
109         def draw(self, context):
110                 layout = self.layout
111
112                 layout.itemO("file.pack_all", text="Pack into .blend file")
113                 layout.itemO("file.unpack_all", text="Unpack into Files...")
114
115                 layout.itemS()
116
117                 layout.itemO("file.make_paths_relative")
118                 layout.itemO("file.make_paths_absolute")
119                 layout.itemO("file.report_missing_files")
120                 layout.itemO("file.find_missing_files")
121
122 class INFO_MT_add(bpy.types.Menu):
123         __space_type__ = 'INFO'
124         __label__ = "Add"
125
126         def draw(self, context):
127                 layout = self.layout
128
129                 layout.operator_context = "EXEC_SCREEN"
130
131                 layout.item_menu_enumO("object.mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH')
132                 layout.item_menu_enumO("object.curve_add", "type", text="Curve", icon='ICON_OUTLINER_OB_CURVE')
133                 layout.item_menu_enumO("object.surface_add", "type", text="Surface", icon='ICON_OUTLINER_OB_SURFACE')
134                 layout.item_menu_enumO("object.metaball_add", "type", 'META', text="Metaball", icon='ICON_OUTLINER_OB_META')
135                 layout.itemO("object.text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
136
137                 layout.itemS()
138
139                 layout.itemO("object.armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
140                 layout.item_enumO("object.add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
141                 layout.item_enumO("object.add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY')
142
143                 layout.itemS()
144
145                 layout.item_enumO("object.add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
146                 layout.item_menu_enumO("object.lamp_add", "type", 'LAMP', text="Lamp", icon='ICON_OUTLINER_OB_LAMP')
147
148 class INFO_MT_game(bpy.types.Menu):
149         __space_type__ = 'INFO'
150         __label__ = "Game"
151
152         def draw(self, context):
153                 layout = self.layout
154
155                 gs = context.scene.game_data
156
157                 layout.itemO("view3d.game_start")
158
159                 layout.itemS()
160
161                 layout.itemR(gs, "show_debug_properties")
162                 layout.itemR(gs, "show_framerate_profile")
163                 layout.itemR(gs, "show_physics_visualization")
164                 layout.itemR(gs, "deprecation_warnings")
165
166 class INFO_MT_render(bpy.types.Menu):
167         __space_type__ = 'INFO'
168         __label__ = "Render"
169
170         def draw(self, context):
171                 layout = self.layout
172                 
173                 rd = context.scene.render_data
174
175                 layout.itemO("screen.render", text="Render Image")
176                 layout.item_booleanO("screen.render", "animation", True, text="Render Animation")
177
178                 layout.itemS()
179
180                 layout.itemO("screen.render_view_show")
181
182 class INFO_MT_help(bpy.types.Menu):
183         __space_type__ = 'INFO'
184         __label__ = "Help"
185
186         def draw(self, context):
187                 layout = self.layout
188
189                 layout.itemO("help.manual")
190                 layout.itemO("help.release_logs")
191
192                 layout.itemS()
193
194                 layout.itemO("help.blender_website")
195                 layout.itemO("help.blender_eshop")
196                 layout.itemO("help.developer_community")
197                 layout.itemO("help.user_community")
198                 layout.itemS()
199                 layout.itemO("help.operator_cheat_sheet")
200                 
201
202 bpy.types.register(INFO_HT_header)
203 bpy.types.register(INFO_MT_file)
204 bpy.types.register(INFO_MT_file_import)
205 bpy.types.register(INFO_MT_file_export)
206 bpy.types.register(INFO_MT_file_external_data)
207 bpy.types.register(INFO_MT_add)
208 bpy.types.register(INFO_MT_game)
209 bpy.types.register(INFO_MT_render)
210 bpy.types.register(INFO_MT_help)
211
212 # Help operators
213
214 import bpy_ops # XXX - should not need to do this
215 del bpy_ops
216
217 class HelpOperator(bpy.types.Operator):
218         def execute(self, context):
219                 try: import webbrowser
220                 except: webbrowser = None
221
222                 if webbrowser:
223                         webbrowser.open(self.__URL__)
224                 else:
225                         raise Exception("Operator requires a full Python installation")
226
227                 return ('FINISHED',)
228
229 class HELP_OT_manual(HelpOperator):
230         __idname__ = "help.manual"
231         __label__ = "Manual"
232         __URL__ = 'http://wiki.blender.org/index.php/Manual'
233
234 class HELP_OT_release_logs(HelpOperator):
235         __idname__ = "help.release_logs"
236         __label__ = "Release Logs"
237         __URL__ = 'http://www.blender.org/development/release-logs/'
238
239 class HELP_OT_blender_website(HelpOperator):
240         __idname__ = "help.blender_website"
241         __label__ = "Blender Website"
242         __URL__ = 'http://www.blender.org/'
243
244 class HELP_OT_blender_eshop(HelpOperator):
245         __idname__ = "help.blender_eshop"
246         __label__ = "Blender e-Shop"
247         __URL__ = 'http://www.blender3d.org/e-shop'
248
249 class HELP_OT_developer_community(HelpOperator):
250         __idname__ = "help.developer_community"
251         __label__ = "Developer Community"
252         __URL__ = 'http://www.blender.org/community/get-involved/'
253
254 class HELP_OT_user_community(HelpOperator):
255         __idname__ = "help.user_community"
256         __label__ = "User Community"
257         __URL__ = 'http://www.blender.org/community/user-community/'
258
259 class HELP_OT_operator_cheat_sheet(bpy.types.Operator):
260         __idname__ = "help.operator_cheat_sheet"
261         __label__ = "Operator Cheet Sheet (new textblock)"
262         def execute(self, context):
263                 op_strings = []
264                 tot = 0
265                 for op_module_name in dir(bpy.ops):
266                         op_module = getattr(bpy.ops, op_module_name)
267                         for op_submodule_name in dir(op_module):
268                                 op = getattr(op_module, op_submodule_name)
269                                 text = repr(op)
270                                 if text.startswith('bpy.ops.'):
271                                         op_strings.append(text)
272                                         tot += 1
273                         
274                         op_strings.append('')
275                 
276                 bpy.ops.text.new() # XXX - assumes new text is always at the end!
277                 textblock = bpy.data.texts[-1]
278                 textblock.write('# %d Operators\n\n' % tot)
279                 textblock.write('\n'.join(op_strings))
280                 textblock.name = "OperatorList.txt"
281                 print("See OperatorList.txt textblock")
282                 return ('FINISHED',)
283
284
285 bpy.ops.add(HELP_OT_manual)
286 bpy.ops.add(HELP_OT_release_logs)
287 bpy.ops.add(HELP_OT_blender_website)
288 bpy.ops.add(HELP_OT_blender_eshop)
289 bpy.ops.add(HELP_OT_developer_community)
290 bpy.ops.add(HELP_OT_user_community)
291 bpy.ops.add(HELP_OT_operator_cheat_sheet)
292