e6adb87bc9fc4d2831299595847dbf160be543c1
[blender-staging.git] / release / scripts / startup / bl_ui / space_info.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Header, Menu
22
23
24 class INFO_HT_header(Header):
25     bl_space_type = 'INFO'
26
27     def draw(self, context):
28         layout = self.layout
29
30         window = context.window
31         scene = context.scene
32         rd = scene.render
33
34         row = layout.row(align=True)
35         row.template_header()
36
37         INFO_MT_editor_menus.draw_collapsible(context, layout)
38
39         if window.screen.show_fullscreen:
40             layout.operator("screen.back_to_previous", icon='SCREEN_BACK', text="Back to Previous")
41             layout.separator()
42         else:
43             layout.template_ID(context.window, "screen", new="screen.new", unlink="screen.delete")
44             layout.template_ID(context.screen, "scene", new="scene.new", unlink="scene.delete")
45
46         layout.separator()
47
48         if rd.has_multiple_engines:
49             layout.prop(rd, "engine", text="")
50
51         layout.separator()
52
53         layout.template_running_jobs()
54
55         layout.template_reports_banner()
56
57         row = layout.row(align=True)
58
59         if bpy.app.autoexec_fail is True and bpy.app.autoexec_fail_quiet is False:
60             row.label("Auto-run disabled", icon='ERROR')
61             if bpy.data.is_saved:
62                 props = row.operator("wm.revert_mainfile", icon='SCREEN_BACK', text="Reload Trusted")
63                 props.use_scripts = True
64
65             row.operator("script.autoexec_warn_clear", text="Ignore")
66
67             # include last so text doesn't push buttons out of the header
68             row.label(bpy.app.autoexec_fail_message)
69             return
70
71         row.operator("wm.splash", text="", icon='BLENDER', emboss=False)
72         row.label(text=scene.statistics(), translate=False)
73
74
75 class INFO_MT_editor_menus(Menu):
76     bl_idname = "INFO_MT_editor_menus"
77     bl_label = ""
78
79     def draw(self, context):
80         self.draw_menus(self.layout, context)
81
82     @staticmethod
83     def draw_menus(layout, context):
84         scene = context.scene
85         rd = scene.render
86
87         layout.menu("INFO_MT_file")
88
89         if rd.use_game_engine:
90             layout.menu("INFO_MT_game")
91         else:
92             layout.menu("INFO_MT_render")
93
94         layout.menu("INFO_MT_window")
95         layout.menu("INFO_MT_help")
96
97
98 class INFO_MT_file(Menu):
99     bl_label = "File"
100
101     def draw(self, context):
102         layout = self.layout
103
104         layout.operator_context = 'INVOKE_AREA'
105         layout.operator("wm.read_homefile", text="New", icon='NEW')
106         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
107         layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT')
108         layout.operator("wm.revert_mainfile", icon='FILE_REFRESH')
109         layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
110         layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
111
112         layout.separator()
113
114         layout.operator_context = 'EXEC_AREA' if context.blend_data.is_saved else 'INVOKE_AREA'
115         layout.operator("wm.save_mainfile", text="Save", icon='FILE_TICK')
116
117         layout.operator_context = 'INVOKE_AREA'
118         layout.operator("wm.save_as_mainfile", text="Save As...", icon='SAVE_AS')
119         layout.operator_context = 'INVOKE_AREA'
120         layout.operator("wm.save_as_mainfile", text="Save Copy...", icon='SAVE_COPY').copy = True
121
122         layout.separator()
123
124         layout.operator("screen.userpref_show", text="User Preferences...", icon='PREFERENCES')
125
126         layout.operator_context = 'INVOKE_AREA'
127         layout.operator("wm.save_homefile", icon='SAVE_PREFS')
128         layout.operator("wm.read_factory_settings", icon='LOAD_FACTORY')
129
130         layout.separator()
131
132         layout.operator_context = 'INVOKE_AREA'
133         layout.operator("wm.link", text="Link", icon='LINK_BLEND')
134         layout.operator("wm.append", text="Append", icon='APPEND_BLEND')
135         layout.menu("INFO_MT_file_previews")
136
137         layout.separator()
138
139         layout.menu("INFO_MT_file_import", icon='IMPORT')
140         layout.menu("INFO_MT_file_export", icon='EXPORT')
141
142         layout.separator()
143
144         layout.menu("INFO_MT_file_external_data", icon='EXTERNAL_DATA')
145
146         layout.separator()
147
148         layout.operator_context = 'EXEC_AREA'
149         if bpy.data.is_dirty and context.user_preferences.view.use_quit_dialog:
150             layout.operator_context = 'INVOKE_SCREEN'  # quit dialog
151         layout.operator("wm.quit_blender", text="Quit", icon='QUIT')
152
153
154 class INFO_MT_file_import(Menu):
155     bl_idname = "INFO_MT_file_import"
156     bl_label = "Import"
157
158     def draw(self, context):
159         if bpy.app.build_options.collada:
160             self.layout.operator("wm.collada_import", text="Collada (Default) (.dae)")
161         if bpy.app.build_options.alembic:
162             self.layout.operator("wm.alembic_import", text="Alembic (.abc)")
163
164
165 class INFO_MT_file_export(Menu):
166     bl_idname = "INFO_MT_file_export"
167     bl_label = "Export"
168
169     def draw(self, context):
170         if bpy.app.build_options.collada:
171             self.layout.operator("wm.collada_export", text="Collada (Default) (.dae)")
172         if bpy.app.build_options.alembic:
173             self.layout.operator("wm.alembic_export", text="Alembic (.abc)")
174
175
176 class INFO_MT_file_external_data(Menu):
177     bl_label = "External Data"
178
179     def draw(self, context):
180         layout = self.layout
181
182         icon = 'CHECKBOX_HLT' if bpy.data.use_autopack else 'CHECKBOX_DEHLT'
183         layout.operator("file.autopack_toggle", icon=icon)
184
185         layout.separator()
186
187         pack_all = layout.row()
188         pack_all.operator("file.pack_all")
189         pack_all.active = not bpy.data.use_autopack
190
191         unpack_all = layout.row()
192         unpack_all.operator("file.unpack_all")
193         unpack_all.active = not bpy.data.use_autopack
194
195         layout.separator()
196
197         layout.operator("file.make_paths_relative")
198         layout.operator("file.make_paths_absolute")
199         layout.operator("file.report_missing_files")
200         layout.operator("file.find_missing_files")
201
202
203 class INFO_MT_file_previews(Menu):
204     bl_label = "Data Previews"
205
206     def draw(self, context):
207         layout = self.layout
208
209         layout.operator("wm.previews_ensure")
210         layout.operator("wm.previews_batch_generate")
211
212         layout.separator()
213
214         layout.operator("wm.previews_clear")
215         layout.operator("wm.previews_batch_clear")
216
217
218 class INFO_MT_game(Menu):
219     bl_label = "Game"
220
221     def draw(self, context):
222         layout = self.layout
223
224         gs = context.scene.game_settings
225
226         layout.operator("view3d.game_start")
227
228         layout.separator()
229
230         layout.prop(gs, "show_debug_properties")
231         layout.prop(gs, "show_framerate_profile")
232         layout.prop(gs, "show_physics_visualization")
233         layout.prop(gs, "use_deprecation_warnings")
234         layout.prop(gs, "use_animation_record")
235         layout.separator()
236         layout.prop(gs, "use_auto_start")
237
238
239 class INFO_MT_render(Menu):
240     bl_label = "Render"
241
242     def draw(self, context):
243         layout = self.layout
244
245         layout.operator("render.render", text="Render Image", icon='RENDER_STILL').use_viewport = True
246         props = layout.operator("render.render", text="Render Animation", icon='RENDER_ANIMATION')
247         props.animation = True
248         props.use_viewport = True
249
250         layout.separator()
251
252         layout.operator("render.opengl", text="OpenGL Render Image")
253         layout.operator("render.opengl", text="OpenGL Render Animation").animation = True
254         layout.menu("INFO_MT_opengl_render")
255
256         layout.separator()
257
258         layout.operator("render.view_show")
259         layout.operator("render.play_rendered_anim", icon='PLAY')
260
261
262 class INFO_MT_opengl_render(Menu):
263     bl_label = "OpenGL Render Options"
264
265     def draw(self, context):
266         layout = self.layout
267
268         rd = context.scene.render
269         layout.prop(rd, "use_antialiasing")
270         layout.prop(rd, "use_full_sample")
271
272         layout.prop_menu_enum(rd, "antialiasing_samples")
273         layout.prop_menu_enum(rd, "alpha_mode")
274
275
276 class INFO_MT_window(Menu):
277     bl_label = "Window"
278
279     def draw(self, context):
280         import sys
281
282         layout = self.layout
283
284         layout.operator("wm.window_duplicate")
285         layout.operator("wm.window_fullscreen_toggle", icon='FULLSCREEN_ENTER')
286
287         layout.separator()
288
289         layout.operator("screen.screenshot")
290         layout.operator("screen.screencast")
291
292         if sys.platform[:3] == "win":
293             layout.separator()
294             layout.operator("wm.console_toggle", icon='CONSOLE')
295
296         if context.scene.render.use_multiview:
297             layout.separator()
298             layout.operator("wm.set_stereo_3d", icon='CAMERA_STEREO')
299
300
301 class INFO_MT_help(Menu):
302     bl_label = "Help"
303
304     def draw(self, context):
305         layout = self.layout
306
307         layout.operator(
308                 "wm.url_open", text="Manual", icon='HELP',
309                 ).url = "https://docs.blender.org/manual/en/dev/"
310         layout.operator(
311                 "wm.url_open", text="Release Log", icon='URL',
312                 ).url = "http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/%d.%d" % bpy.app.version[:2]
313         layout.separator()
314
315         layout.operator(
316                 "wm.url_open", text="Blender Website", icon='URL',
317                 ).url = "https://www.blender.org"
318         layout.operator(
319                 "wm.url_open", text="Blender Store", icon='URL',
320                 ).url = "https://store.blender.org"
321         layout.operator(
322                 "wm.url_open", text="Developer Community", icon='URL',
323                 ).url = "https://www.blender.org/get-involved/"
324         layout.operator(
325                 "wm.url_open", text="User Community", icon='URL',
326                 ).url = "https://www.blender.org/support/user-community"
327         layout.separator()
328         layout.operator(
329                 "wm.url_open", text="Report a Bug", icon='URL',
330                 ).url = "https://developer.blender.org/maniphest/task/edit/form/1"
331         layout.separator()
332
333         layout.operator(
334                 "wm.url_open", text="Python API Reference", icon='URL',
335                 ).url = bpy.types.WM_OT_doc_view._prefix
336
337         layout.operator("wm.operator_cheat_sheet", icon='TEXT')
338         layout.operator("wm.sysinfo", icon='TEXT')
339         layout.separator()
340
341         layout.operator("wm.splash", icon='BLENDER')
342
343
344 classes = (
345     INFO_HT_header,
346     INFO_MT_editor_menus,
347     INFO_MT_file,
348     INFO_MT_file_export,
349     INFO_MT_file_external_data,
350     INFO_MT_file_import,
351     INFO_MT_file_previews,
352     INFO_MT_game,
353     INFO_MT_help,
354     INFO_MT_opengl_render,
355     INFO_MT_render,
356     INFO_MT_window,
357 )
358
359 if __name__ == "__main__":  # only for live edit.
360     from bpy.utils import register_class
361     for cls in classes:
362         register_class(cls)