12005ea3ecb6f9ad0f29f3483fa1587f27013db9
[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                 rd = context.scene.render_data
12                 
13                 layout.template_header()
14
15                 if context.area.show_menus:
16                         row = layout.row()
17                         row.itemM("INFO_MT_file")
18                         row.itemM("INFO_MT_add")
19                         if rd.use_game_engine:
20                                 row.itemM("INFO_MT_game")
21                         else:
22                                 row.itemM("INFO_MT_render")
23                         row.itemM("INFO_MT_help")
24
25                 layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
26                 layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
27
28                 if rd.multiple_engines:
29                         layout.itemR(rd, "engine", text="")
30
31                 layout.itemS()
32
33                 layout.template_operator_search()
34                 layout.template_running_jobs()
35                         
36 class INFO_MT_file(bpy.types.Menu):
37         __space_type__ = "INFO"
38         __label__ = "File"
39
40         def draw(self, context):
41                 layout = self.layout
42
43                 layout.operator_context = "EXEC_AREA"
44                 layout.itemO("wm.read_homefile", text="New")
45                 layout.operator_context = "INVOKE_AREA"
46                 layout.itemO("wm.open_mainfile", text="Open...")
47                 layout.item_menu_enumO("wm.open_recentfile", "file", text="Open Recent")
48                 layout.itemO("wm.recover_last_session")
49
50                 layout.itemS()
51
52                 layout.operator_context = "EXEC_AREA"
53                 layout.itemO("wm.save_mainfile", text="Save")
54                 layout.operator_context = "INVOKE_AREA"
55                 layout.itemO("wm.save_as_mainfile", text="Save As...")
56                 layout.itemO("screen.userpref_show", text="User Preferences...")
57
58                 layout.itemS()
59
60                 layout.itemM("INFO_MT_file_import")
61                 layout.itemM("INFO_MT_file_export")
62
63                 layout.itemS()
64
65                 layout.itemM("INFO_MT_file_external_data")
66
67                 layout.itemS()
68
69                 layout.operator_context = "EXEC_AREA"
70                 layout.itemO("wm.exit_blender", text="Quit")
71
72 class INFO_MT_file_import(bpy.types.Menu):
73         __space_type__ = "INFO"
74         __label__ = "Import"
75
76         def draw(self, context):
77                 layout = self.layout
78
79 class INFO_MT_file_export(bpy.types.Menu):
80         __space_type__ = "INFO"
81         __label__ = "Export"
82
83         def draw(self, context):
84                 layout = self.layout
85
86                 layout.itemO("export.ply", text="PLY")
87
88 class INFO_MT_file_external_data(bpy.types.Menu):
89         __space_type__ = "INFO"
90         __label__ = "External Data"
91
92         def draw(self, context):
93                 layout = self.layout
94
95                 layout.itemO("file.pack_all", text="Pack into .blend file")
96                 layout.itemO("file.unpack_all", text="Unpack into Files...")
97
98                 layout.itemS()
99
100                 layout.itemO("file.make_paths_relative")
101                 layout.itemO("file.make_paths_absolute")
102                 layout.itemO("file.report_missing_files")
103                 layout.itemO("file.find_missing_files")
104
105 class INFO_MT_add(bpy.types.Menu):
106         __space_type__ = "INFO"
107         __label__ = "Add"
108
109         def draw(self, context):
110                 layout = self.layout
111
112                 layout.operator_context = "EXEC_SCREEN"
113
114                 layout.item_menu_enumO( "OBJECT_OT_mesh_add", "type", text="Mesh", icon='ICON_OUTLINER_OB_MESH')
115                 layout.item_menu_enumO( "OBJECT_OT_curve_add", "type", text="Curve", icon='ICON_OUTLINER_OB_CURVE')
116                 layout.item_menu_enumO( "OBJECT_OT_surface_add", "type", text="Surface", icon='ICON_OUTLINER_OB_SURFACE')
117                 layout.item_menu_enumO( "OBJECT_OT_metaball_add", "type", 'META', icon='ICON_OUTLINER_OB_META')
118                 layout.itemO("OBJECT_OT_text_add", text="Text", icon='ICON_OUTLINER_OB_FONT')
119
120                 layout.itemS()
121
122                 layout.itemO("OBJECT_OT_armature_add", text="Armature", icon='ICON_OUTLINER_OB_ARMATURE')
123                 layout.item_enumO("OBJECT_OT_object_add", "type", 'LATTICE', icon='ICON_OUTLINER_OB_LATTICE')
124                 layout.item_enumO("OBJECT_OT_object_add", "type", 'EMPTY', icon='ICON_OUTLINER_OB_EMPTY')
125
126                 layout.itemS()
127
128                 layout.item_enumO("OBJECT_OT_object_add", "type", 'CAMERA', icon='ICON_OUTLINER_OB_CAMERA')
129                 layout.item_enumO("OBJECT_OT_object_add", "type", 'LAMP', icon='ICON_OUTLINER_OB_LAMP')
130
131 class INFO_MT_game(bpy.types.Menu):
132         __space_type__ = "INFO"
133         __label__ = "Game"
134
135         def draw(self, context):
136                 layout = self.layout
137
138                 layout.itemO("view3d.game_start")
139
140 class INFO_MT_render(bpy.types.Menu):
141         __space_type__ = "INFO"
142         __label__ = "Render"
143
144         def draw(self, context):
145                 layout = self.layout
146                 
147                 rd = context.scene.render_data
148
149                 layout.itemO("screen.render", text="Render Image")
150                 layout.item_booleanO("screen.render", "animation", True, text="Render Animation")
151
152                 layout.itemS()
153
154                 layout.itemO("screen.render_view_show")
155
156 class INFO_MT_help(bpy.types.Menu):
157         __space_type__ = "INFO"
158         __label__ = "Help"
159
160         def draw(self, context):
161                 layout = self.layout
162
163                 layout.itemO("help.manual")
164                 layout.itemO("help.release_logs")
165
166                 layout.itemS()
167
168                 layout.itemO("help.blender_website")
169                 layout.itemO("help.blender_eshop")
170                 layout.itemO("help.developer_community")
171                 layout.itemO("help.user_community")
172
173 bpy.types.register(INFO_HT_header)
174 bpy.types.register(INFO_MT_file)
175 bpy.types.register(INFO_MT_file_import)
176 bpy.types.register(INFO_MT_file_export)
177 bpy.types.register(INFO_MT_file_external_data)
178 bpy.types.register(INFO_MT_add)
179 bpy.types.register(INFO_MT_game)
180 bpy.types.register(INFO_MT_render)
181 bpy.types.register(INFO_MT_help)
182
183 # Help operators
184
185 import bpy_ops # XXX - should not need to do this
186 del bpy_ops
187
188 class HelpOperator(bpy.types.Operator):
189         def execute(self, context):
190                 try: import webbrowser
191                 except: webbrowser = None
192
193                 if webbrowser:
194                         webbrowser.open(self.__URL__)
195                 else:
196                         raise Exception("Operator requires a full Python installation")
197
198                 return ('FINISHED',)
199
200 class HELP_OT_manual(HelpOperator):
201         __idname__ = "help.manual"
202         __label__ = "Manual"
203         __URL__ = 'http://wiki.blender.org/index.php/Manual'
204
205 class HELP_OT_release_logs(HelpOperator):
206         __idname__ = "help.release_logs"
207         __label__ = "Release Logs"
208         __URL__ = 'http://www.blender.org/development/release-logs/'
209
210 class HELP_OT_blender_website(HelpOperator):
211         __idname__ = "help.blender_website"
212         __label__ = "Blender Website"
213         __URL__ = 'http://www.blender.org/'
214
215 class HELP_OT_blender_eshop(HelpOperator):
216         __idname__ = "help.blender_eshop"
217         __label__ = "Blender e-Shop"
218         __URL__ = 'http://www.blender3d.org/e-shop'
219
220 class HELP_OT_developer_community(HelpOperator):
221         __idname__ = "help.developer_community"
222         __label__ = "Developer Community"
223         __URL__ = 'http://www.blender.org/community/get-involved/'
224
225 class HELP_OT_user_community(HelpOperator):
226         __idname__ = "help.user_community"
227         __label__ = "User Community"
228         __URL__ = 'http://www.blender.org/community/user-community/'
229
230 bpy.ops.add(HELP_OT_manual)
231 bpy.ops.add(HELP_OT_release_logs)
232 bpy.ops.add(HELP_OT_blender_website)
233 bpy.ops.add(HELP_OT_blender_eshop)
234 bpy.ops.add(HELP_OT_developer_community)
235 bpy.ops.add(HELP_OT_user_community)
236