Revert "Icons: Add GPencil Extrude and Radius icons"
[blender.git] / release / scripts / startup / bl_ui / properties_output.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2
3 #
4 #  This program is free software; you can redistribute it and/or
5 #  modify it under the terms of the GNU General Public License
6 #  as published by the Free Software Foundation; either version 2
7 #  of the License, or (at your option) any later version.
8 #
9 #  This program is distributed in the hope that it will be useful,
10 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #  GNU General Public License for more details.
13 #
14 #  You should have received a copy of the GNU General Public License
15 #  along with this program; if not, write to the Free Software Foundation,
16 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18 # ##### END GPL LICENSE BLOCK #####
19
20 # <pep8 compliant>
21 import bpy
22 from bpy.types import Menu, Panel, UIList
23 from bl_operators.presets import PresetMenu
24
25
26 class RENDER_PT_presets(PresetMenu):
27     bl_label = "Render Presets"
28     preset_subdir = "render"
29     preset_operator = "script.execute_preset"
30     preset_add_operator = "render.preset_add"
31
32
33 class RENDER_PT_ffmpeg_presets(PresetMenu):
34     bl_label = "FFMPEG Presets"
35     preset_subdir = "ffmpeg"
36     preset_operator = "script.python_file_run"
37
38
39 class RENDER_MT_framerate_presets(Menu):
40     bl_label = "Frame Rate Presets"
41     preset_subdir = "framerate"
42     preset_operator = "script.execute_preset"
43     draw = Menu.draw_preset
44
45
46 class RenderOutputButtonsPanel:
47     bl_space_type = 'PROPERTIES'
48     bl_region_type = 'WINDOW'
49     bl_context = "output"
50     # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
51
52     @classmethod
53     def poll(cls, context):
54         return (context.engine in cls.COMPAT_ENGINES)
55
56
57 class RENDER_PT_dimensions(RenderOutputButtonsPanel, Panel):
58     bl_label = "Dimensions"
59     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
60
61     _frame_rate_args_prev = None
62     _preset_class = None
63
64     def draw_header_preset(self, context):
65         RENDER_PT_presets.draw_panel_header(self.layout)
66
67     @staticmethod
68     def _draw_framerate_label(*args):
69         # avoids re-creating text string each draw
70         if RENDER_PT_dimensions._frame_rate_args_prev == args:
71             return RENDER_PT_dimensions._frame_rate_ret
72
73         fps, fps_base, preset_label = args
74
75         if fps_base == 1.0:
76             fps_rate = round(fps)
77         else:
78             fps_rate = round(fps / fps_base, 2)
79
80         # TODO: Change the following to iterate over existing presets
81         custom_framerate = (fps_rate not in {23.98, 24, 25, 29.97, 30, 50, 59.94, 60})
82
83         if custom_framerate is True:
84             fps_label_text = f"Custom ({fps_rate!r} fps)"
85             show_framerate = True
86         else:
87             fps_label_text = f"{fps_rate!r} fps"
88             show_framerate = (preset_label == "Custom")
89
90         RENDER_PT_dimensions._frame_rate_args_prev = args
91         RENDER_PT_dimensions._frame_rate_ret = args = (fps_label_text, show_framerate)
92         return args
93
94     @staticmethod
95     def draw_framerate(layout, sub, rd):
96         if RENDER_PT_dimensions._preset_class is None:
97             RENDER_PT_dimensions._preset_class = bpy.types.RENDER_MT_framerate_presets
98
99         args = rd.fps, rd.fps_base, RENDER_PT_dimensions._preset_class.bl_label
100         fps_label_text, show_framerate = RENDER_PT_dimensions._draw_framerate_label(*args)
101
102         sub.menu("RENDER_MT_framerate_presets", text=fps_label_text)
103
104         if show_framerate:
105             col = layout.column(align=True)
106             col.prop(rd, "fps")
107             col.prop(rd, "fps_base", text="Base")
108
109     def draw(self, context):
110         layout = self.layout
111         layout.use_property_split = True
112         layout.use_property_decorate = False  # No animation.
113
114         scene = context.scene
115         rd = scene.render
116
117         col = layout.column(align=True)
118         col.prop(rd, "resolution_x", text="Resolution X")
119         col.prop(rd, "resolution_y", text="Y")
120         col.prop(rd, "resolution_percentage", text="%")
121
122         col = layout.column(align=True)
123         col.prop(rd, "pixel_aspect_x", text="Aspect X")
124         col.prop(rd, "pixel_aspect_y", text="Y")
125
126         col = layout.column(align=True)
127         col.prop(rd, "use_border")
128         sub = col.column(align=True)
129         sub.active = rd.use_border
130         sub.prop(rd, "use_crop_to_border")
131
132         col = layout.column(align=True)
133         col.prop(scene, "frame_start", text="Frame Start")
134         col.prop(scene, "frame_end", text="End")
135         col.prop(scene, "frame_step", text="Step")
136
137         col = layout.split()
138         col.alignment = 'RIGHT'
139         col.label(text="Frame Rate")
140         self.draw_framerate(layout, col, rd)
141
142
143 class RENDER_PT_frame_remapping(RenderOutputButtonsPanel, Panel):
144     bl_label = "Time Remapping"
145     bl_parent_id = "RENDER_PT_dimensions"
146     bl_options = {'DEFAULT_CLOSED'}
147     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
148
149     def draw(self, context):
150         layout = self.layout
151         layout.use_property_split = True
152         layout.use_property_decorate = False  # No animation.
153
154         rd = context.scene.render
155
156         col = layout.column(align=True)
157         col.prop(rd, "frame_map_old", text="Old")
158         col.prop(rd, "frame_map_new", text="New")
159
160
161 class RENDER_PT_post_processing(RenderOutputButtonsPanel, Panel):
162     bl_label = "Post Processing"
163     bl_options = {'DEFAULT_CLOSED'}
164     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
165
166     def draw(self, context):
167         layout = self.layout
168         layout.use_property_split = True
169
170         rd = context.scene.render
171
172         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
173         col = flow.column()
174         col.prop(rd, "use_compositing")
175         col = flow.column()
176         col.prop(rd, "use_sequencer")
177
178         layout.prop(rd, "dither_intensity", text="Dither", slider=True)
179
180
181 class RENDER_PT_stamp(RenderOutputButtonsPanel, Panel):
182     bl_label = "Metadata"
183     bl_options = {'DEFAULT_CLOSED'}
184     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
185
186     def draw(self, context):
187         layout = self.layout
188         layout.use_property_split = True
189         layout.use_property_decorate = False  # No animation.
190
191         rd = context.scene.render
192
193         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
194
195         col = flow.column()
196         col.prop(rd, "use_stamp_date", text="Date")
197         col = flow.column()
198         col.prop(rd, "use_stamp_time", text="Time")
199
200         col = flow.column()
201         col.prop(rd, "use_stamp_render_time", text="Render Time")
202         col = flow.column()
203         col.prop(rd, "use_stamp_frame", text="Frame")
204         col = flow.column()
205         col.prop(rd, "use_stamp_frame_range", text="Frame Range")
206         col = flow.column()
207         col.prop(rd, "use_stamp_memory", text="Memory")
208         col = flow.column()
209         col.prop(rd, "use_stamp_hostname", text="Hostname")
210
211         col = flow.column()
212         col.prop(rd, "use_stamp_camera", text="Camera")
213         col = flow.column()
214         col.prop(rd, "use_stamp_lens", text="Lens")
215
216         col = flow.column()
217         col.prop(rd, "use_stamp_scene", text="Scene")
218         col = flow.column()
219         col.prop(rd, "use_stamp_marker", text="Marker")
220
221         col = flow.column()
222         col.prop(rd, "use_stamp_filename", text="Filename")
223
224         col = flow.column()
225         col.prop(rd, "use_stamp_sequencer_strip", text="Strip Name")
226
227         if rd.use_sequencer:
228             col = flow.column()
229             col.prop(rd, "use_stamp_strip_meta", text="Use Strip Metadata")
230
231
232 class RENDER_PT_stamp_note(RenderOutputButtonsPanel, Panel):
233     bl_label = "Note"
234     bl_parent_id = "RENDER_PT_stamp"
235     bl_options = {'DEFAULT_CLOSED'}
236     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
237
238     def draw_header(self, context):
239         rd = context.scene.render
240
241         self.layout.prop(rd, "use_stamp_note", text="")
242
243     def draw(self, context):
244         layout = self.layout
245
246         rd = context.scene.render
247
248         layout.active = rd.use_stamp_note
249         layout.prop(rd, "stamp_note_text", text="")
250
251
252 class RENDER_PT_stamp_burn(RenderOutputButtonsPanel, Panel):
253     bl_label = "Burn Into Image"
254     bl_parent_id = "RENDER_PT_stamp"
255     bl_options = {'DEFAULT_CLOSED'}
256     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
257
258     def draw_header(self, context):
259         rd = context.scene.render
260
261         self.layout.prop(rd, "use_stamp", text="")
262
263     def draw(self, context):
264         layout = self.layout
265
266         rd = context.scene.render
267
268         layout.use_property_split = True
269
270         col = layout.column()
271         col.active = rd.use_stamp
272         col.prop(rd, "stamp_font_size", text="Font Size")
273         col.column().prop(rd, "stamp_foreground", slider=True)
274         col.column().prop(rd, "stamp_background", slider=True)
275         col.prop(rd, "use_stamp_labels", text="Include Labels")
276
277
278 class RENDER_PT_output(RenderOutputButtonsPanel, Panel):
279     bl_label = "Output"
280     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
281
282     def draw(self, context):
283         layout = self.layout
284         layout.use_property_split = False
285         layout.use_property_decorate = False  # No animation.
286
287         rd = context.scene.render
288         image_settings = rd.image_settings
289
290         layout.prop(rd, "filepath", text="")
291
292         layout.use_property_split = True
293
294         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=False)
295
296         col = flow.column()
297         col.active = not rd.is_movie_format
298         col.prop(rd, "use_overwrite")
299         col = flow.column()
300         col.active = not rd.is_movie_format
301         col.prop(rd, "use_placeholder")
302         col = flow.column()
303         col.prop(rd, "use_file_extension")
304         col = flow.column()
305         col.prop(rd, "use_render_cache")
306
307         layout.template_image_settings(image_settings, color_management=False)
308
309
310 class RENDER_PT_output_views(RenderOutputButtonsPanel, Panel):
311     bl_label = "Views"
312     bl_parent_id = "RENDER_PT_output"
313     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
314
315     @classmethod
316     def poll(self, context):
317         rd = context.scene.render
318         return rd.use_multiview
319
320     def draw(self, context):
321         layout = self.layout
322         layout.use_property_split = False
323         layout.use_property_decorate = False  # No animation.
324
325         rd = context.scene.render
326         layout.template_image_views(rd.image_settings)
327
328
329 class RENDER_PT_encoding(RenderOutputButtonsPanel, Panel):
330     bl_label = "Encoding"
331     bl_parent_id = "RENDER_PT_output"
332     bl_options = {'DEFAULT_CLOSED'}
333     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
334
335     def draw_header_preset(self, context):
336         RENDER_PT_ffmpeg_presets.draw_panel_header(self.layout)
337
338     @classmethod
339     def poll(cls, context):
340         rd = context.scene.render
341         return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
342
343     def draw(self, context):
344         layout = self.layout
345         layout.use_property_split = True
346         layout.use_property_decorate = False
347
348         rd = context.scene.render
349         ffmpeg = rd.ffmpeg
350
351         layout.prop(rd.ffmpeg, "format")
352         layout.prop(ffmpeg, "use_autosplit")
353
354
355 class RENDER_PT_encoding_video(RenderOutputButtonsPanel, Panel):
356     bl_label = "Video"
357     bl_parent_id = "RENDER_PT_encoding"
358     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
359
360     @classmethod
361     def poll(cls, context):
362         rd = context.scene.render
363         return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
364
365     def draw(self, context):
366         layout = self.layout
367         layout.use_property_split = True
368         layout.use_property_decorate = False
369
370         self.draw_vcodec(context)
371
372     def draw_vcodec(self, context):
373         """Video codec options."""
374         layout = self.layout
375         ffmpeg = context.scene.render.ffmpeg
376
377         needs_codec = ffmpeg.format in {'AVI', 'QUICKTIME', 'MKV', 'OGG', 'MPEG4'}
378         if needs_codec:
379             layout.prop(ffmpeg, "codec")
380
381         if needs_codec and ffmpeg.codec == 'NONE':
382             return
383
384         if ffmpeg.codec in {'DNXHD'}:
385             layout.prop(ffmpeg, "use_lossless_output")
386
387         # Output quality
388         use_crf = needs_codec and ffmpeg.codec in {'H264', 'MPEG4', 'WEBM'}
389         if use_crf:
390             layout.prop(ffmpeg, "constant_rate_factor")
391
392         # Encoding speed
393         layout.prop(ffmpeg, "ffmpeg_preset")
394         # I-frames
395         layout.prop(ffmpeg, "gopsize")
396         # B-Frames
397         split = layout.split(factor=0.5)
398         split.prop(ffmpeg, "use_max_b_frames", text="Max B-frames")
399         pbox = split.column()
400         pbox.prop(ffmpeg, "max_b_frames", text="")
401         pbox.enabled = ffmpeg.use_max_b_frames
402
403         if not use_crf or ffmpeg.constant_rate_factor == 'NONE':
404             col = layout.column()
405
406             sub = col.column(align=True)
407             sub.prop(ffmpeg, "video_bitrate")
408             sub.prop(ffmpeg, "minrate", text="Minimum")
409             sub.prop(ffmpeg, "maxrate", text="Maximum")
410
411             col.prop(ffmpeg, "buffersize", text="Buffer")
412
413             col.separator()
414
415             col.prop(ffmpeg, "muxrate", text="Mux Rate")
416             col.prop(ffmpeg, "packetsize", text="Mux Packet Size")
417
418
419 class RENDER_PT_encoding_audio(RenderOutputButtonsPanel, Panel):
420     bl_label = "Audio"
421     bl_parent_id = "RENDER_PT_encoding"
422     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
423
424     @classmethod
425     def poll(cls, context):
426         rd = context.scene.render
427         return rd.image_settings.file_format in {'FFMPEG', 'XVID', 'H264', 'THEORA'}
428
429     def draw(self, context):
430         layout = self.layout
431         layout.use_property_split = True
432         layout.use_property_decorate = False
433
434         rd = context.scene.render
435         ffmpeg = rd.ffmpeg
436
437         if ffmpeg.format != 'MP3':
438             layout.prop(ffmpeg, "audio_codec", text="Audio Codec")
439
440         if ffmpeg.audio_codec != 'NONE':
441             layout.prop(ffmpeg, "audio_bitrate")
442             layout.prop(ffmpeg, "audio_volume", slider=True)
443
444
445 class RENDER_UL_renderviews(UIList):
446     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
447         view = item
448         if self.layout_type in {'DEFAULT', 'COMPACT'}:
449             if view.name in {"left", "right"}:
450                 layout.label(text=view.name, icon_value=icon + (not view.use))
451             else:
452                 layout.prop(view, "name", text="", index=index, icon_value=icon, emboss=False)
453             layout.prop(view, "use", text="", index=index)
454
455         elif self.layout_type == 'GRID':
456             layout.alignment = 'CENTER'
457             layout.label(text="", icon_value=icon + (not view.use))
458
459
460 class RENDER_PT_stereoscopy(RenderOutputButtonsPanel, Panel):
461     bl_label = "Stereoscopy"
462     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
463     bl_options = {'DEFAULT_CLOSED'}
464
465     def draw_header(self, context):
466         rd = context.scene.render
467         self.layout.prop(rd, "use_multiview", text="")
468
469     def draw(self, context):
470         layout = self.layout
471
472         scene = context.scene
473         rd = scene.render
474         rv = rd.views.active
475
476         layout.active = rd.use_multiview
477         basic_stereo = rd.views_format == 'STEREO_3D'
478
479         row = layout.row()
480         row.prop(rd, "views_format")
481
482         if basic_stereo:
483             row = layout.row()
484             row.template_list("RENDER_UL_renderviews", "name", rd, "stereo_views", rd.views, "active_index", rows=2)
485
486             row = layout.row()
487             row.label(text="File Suffix:")
488             row.prop(rv, "file_suffix", text="")
489
490         else:
491             row = layout.row()
492             row.template_list("RENDER_UL_renderviews", "name", rd, "views", rd.views, "active_index", rows=2)
493
494             col = row.column(align=True)
495             col.operator("scene.render_view_add", icon='ADD', text="")
496             col.operator("scene.render_view_remove", icon='REMOVE', text="")
497
498             row = layout.row()
499             row.label(text="Camera Suffix:")
500             row.prop(rv, "camera_suffix", text="")
501
502
503 classes = (
504     RENDER_PT_presets,
505     RENDER_PT_ffmpeg_presets,
506     RENDER_MT_framerate_presets,
507     RENDER_PT_dimensions,
508     RENDER_PT_frame_remapping,
509     RENDER_PT_output,
510     RENDER_PT_output_views,
511     RENDER_PT_encoding,
512     RENDER_PT_encoding_video,
513     RENDER_PT_encoding_audio,
514     RENDER_PT_stamp,
515     RENDER_PT_stamp_note,
516     RENDER_PT_stamp_burn,
517     RENDER_UL_renderviews,
518     RENDER_PT_stereoscopy,
519     RENDER_PT_post_processing,
520 )
521
522 if __name__ == "__main__":  # only for live edit.
523     from bpy.utils import register_class
524     for cls in classes:
525         register_class(cls)