Fix #100973: Node Wrangler: Previewing node if hierarchy not active
[blender-addons.git] / amaranth / render / final_resolution.py
blobd4f77cd816454c02c3be7b54b0610112573df997
1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 """
6 UI: Final Resolution
8 Always wondered how big the render was going to be when rendering at a
9 certain %?
10 This feature displays a "Final Resolution" label with the size in pixels
11 of your render, it also displays the size for border renders.
13 On the 'Dimensions' panel, Render properties.
14 """
15 import bpy
18 def render_final_resolution_ui(self, context):
20 rd = context.scene.render
21 final_res_x = (rd.resolution_x * rd.resolution_percentage) / 100
22 final_res_y = (rd.resolution_y * rd.resolution_percentage) / 100
23 final_res_x_border = round(
24 (final_res_x * (rd.border_max_x - rd.border_min_x)))
25 final_res_y_border = round(
26 (final_res_y * (rd.border_max_y - rd.border_min_y)))
28 layout = self.layout
29 layout.use_property_split = True
30 layout.use_property_decorate = False
32 layout.separator()
33 box = layout.box()
34 col = box.column(align=True)
35 col.active = False
36 split = col.split(factor=0.4)
38 col = split.column(align=True)
39 row = col.row()
40 row.alignment = 'RIGHT'
41 row.label(text="Render Resolution")
43 if rd.use_border:
44 row = col.row()
45 row.alignment = 'RIGHT'
46 row.label(text="Region")
48 col = split.column(align=True)
49 col.label(text="{} x {}".format(
50 str(final_res_x)[:-2], str(final_res_y)[:-2]))
52 if rd.use_border:
53 col.label(text="{} x {}".format(
54 str(final_res_x_border), str(final_res_y_border)))
57 def register():
58 bpy.types.RENDER_PT_format.append(render_final_resolution_ui)
61 def unregister():
62 bpy.types.RENDER_PT_format.remove(render_final_resolution_ui)