2.5:
[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
64                 layout.itemM("INFO_MT_file_import")
65                 layout.itemM("INFO_MT_file_export")
66
67                 layout.itemS()
68
69                 layout.itemM("INFO_MT_file_external_data")
70
71                 layout.itemS()
72
73                 layout.operator_context = "EXEC_AREA"
74                 layout.itemO("wm.exit_blender", text="Quit")
75
76 class INFO_MT_file_import(bpy.types.Menu):
77         __space_type__ = "INFO"
78         __label__ = "Import"
79
80         def draw(self, context):
81                 layout = self.layout
82
83 class INFO_MT_file_export(bpy.types.Menu):
84         __space_type__ = "INFO"
85         __label__ = "Export"
86
87         def draw(self, context):
88                 layout = self.layout
89
90                 layout.itemO("export.ply", text="PLY")
91
92 class INFO_MT_file_external_data(bpy.types.Menu):
93         __space_type__ = "INFO"
94         __label__ = "External Data"
95
96         def draw(self, context):
97                 layout = self.layout
98
99                 layout.itemO("file.pack_all", text="Pack into .blend file")
100                 layout.itemO("file.unpack_all", text="Unpack into Files...")
101
102                 layout.itemS()
103
104                 layout.itemO("file.make_paths_relative")
105                 layout.itemO("file.make_paths_absolute")
106                 layout.itemO("file.report_missing_files")
107                 layout.itemO("file.find_missing_files")
108
109 class INFO_MT_add(bpy.types.Menu):
110         __space_type__ = "INFO"
111         __label__ = "Add"
112
113         def draw(self, context):
114                 layout = self.layout
115
116                 layout.operator_context = "EXEC_SCREEN"
117
118                 layout.item_menu_enumO( "object.mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH')
119                 layout.item_menu_enumO( "object.curve_add", "type", text="Curve", icon='ICON_OUTLINER_OB_CURVE')
120                 layout.item_menu_enumO( "object.surface_add", "type", text="Surface", icon='ICON_OUTLINER_OB_SURFACE')
121                 layout.item_menu_enumO( "object.metaball_add", "type", 'META', icon='ICON_OUTLINER_OB_META')
122                 layout.itemO("object.text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
123
124                 layout.itemS()
125
126                 layout.itemO("object.armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
127                 layout.item_enumO("object.object_add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
128                 layout.item_enumO("object.object_add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY')
129
130                 layout.itemS()
131
132                 layout.item_enumO("object.object_add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
133                 layout.item_enumO("object.object_add", "type", 'LAMP', icon='ICON_OUTLINER_OB_LAMP')
134
135 class INFO_MT_game(bpy.types.Menu):
136         __space_type__ = "INFO"
137         __label__ = "Game"
138
139         def draw(self, context):
140                 layout = self.layout
141
142                 gs = context.scene.game_data
143
144                 layout.itemO("view3d.game_start")
145
146                 layout.itemS()
147
148                 layout.itemR(gs, "show_debug_properties")
149                 layout.itemR(gs, "show_framerate_profile")
150                 layout.itemR(gs, "show_physics_visualization")
151                 layout.itemR(gs, "deprecation_warnings")
152
153 class INFO_MT_render(bpy.types.Menu):
154         __space_type__ = "INFO"
155         __label__ = "Render"
156
157         def draw(self, context):
158                 layout = self.layout
159                 
160                 rd = context.scene.render_data
161
162                 layout.itemO("screen.render", text="Render Image")
163                 layout.item_booleanO("screen.render", "animation", True, text="Render Animation")
164
165                 layout.itemS()
166
167                 layout.itemO("screen.render_view_show")
168
169 class INFO_MT_help(bpy.types.Menu):
170         __space_type__ = "INFO"
171         __label__ = "Help"
172
173         def draw(self, context):
174                 layout = self.layout
175
176                 layout.itemO("help.manual")
177                 layout.itemO("help.release_logs")
178
179                 layout.itemS()
180
181                 layout.itemO("help.blender_website")
182                 layout.itemO("help.blender_eshop")
183                 layout.itemO("help.developer_community")
184                 layout.itemO("help.user_community")
185
186 bpy.types.register(INFO_HT_header)
187 bpy.types.register(INFO_MT_file)
188 bpy.types.register(INFO_MT_file_import)
189 bpy.types.register(INFO_MT_file_export)
190 bpy.types.register(INFO_MT_file_external_data)
191 bpy.types.register(INFO_MT_add)
192 bpy.types.register(INFO_MT_game)
193 bpy.types.register(INFO_MT_render)
194 bpy.types.register(INFO_MT_help)
195
196 # Help operators
197
198 import bpy_ops # XXX - should not need to do this
199 del bpy_ops
200
201 class HelpOperator(bpy.types.Operator):
202         def execute(self, context):
203                 try: import webbrowser
204                 except: webbrowser = None
205
206                 if webbrowser:
207                         webbrowser.open(self.__URL__)
208                 else:
209                         raise Exception("Operator requires a full Python installation")
210
211                 return ('FINISHED',)
212
213 class HELP_OT_manual(HelpOperator):
214         __idname__ = "help.manual"
215         __label__ = "Manual"
216         __URL__ = 'http://wiki.blender.org/index.php/Manual'
217
218 class HELP_OT_release_logs(HelpOperator):
219         __idname__ = "help.release_logs"
220         __label__ = "Release Logs"
221         __URL__ = 'http://www.blender.org/development/release-logs/'
222
223 class HELP_OT_blender_website(HelpOperator):
224         __idname__ = "help.blender_website"
225         __label__ = "Blender Website"
226         __URL__ = 'http://www.blender.org/'
227
228 class HELP_OT_blender_eshop(HelpOperator):
229         __idname__ = "help.blender_eshop"
230         __label__ = "Blender e-Shop"
231         __URL__ = 'http://www.blender3d.org/e-shop'
232
233 class HELP_OT_developer_community(HelpOperator):
234         __idname__ = "help.developer_community"
235         __label__ = "Developer Community"
236         __URL__ = 'http://www.blender.org/community/get-involved/'
237
238 class HELP_OT_user_community(HelpOperator):
239         __idname__ = "help.user_community"
240         __label__ = "User Community"
241         __URL__ = 'http://www.blender.org/community/user-community/'
242
243 bpy.ops.add(HELP_OT_manual)
244 bpy.ops.add(HELP_OT_release_logs)
245 bpy.ops.add(HELP_OT_blender_website)
246 bpy.ops.add(HELP_OT_blender_eshop)
247 bpy.ops.add(HELP_OT_developer_community)
248 bpy.ops.add(HELP_OT_user_community)
249