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