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