Fix T98039: Node Wrangler node preview no longer working
[blender-addons.git] / add_camera_rigs / ui_panels.py
blobc6066147ad69457db0abc062ba3a0ad251a54fc2
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 import bpy
4 from bpy.types import Panel
6 from .operators import get_rig_and_cam, CameraRigMixin
9 class ADD_CAMERA_RIGS_PT_camera_rig_ui(Panel, CameraRigMixin):
10 bl_label = "Camera Rig"
11 bl_space_type = 'VIEW_3D'
12 bl_region_type = 'UI'
13 bl_category = 'Item'
15 def draw(self, context):
16 active_object = context.active_object
17 rig, cam = get_rig_and_cam(context.active_object)
18 pose_bones = rig.pose.bones
19 cam_data = cam.data
20 layout = self.layout
22 # Camera lens
23 if rig["rig_id"].lower() in ("dolly_rig", "crane_rig"):
24 layout.prop(pose_bones["Camera"], '["lens"]',
25 text="Focal Length (mm)")
27 col = layout.column(align=True)
28 col.label(text="Clipping:")
29 col.prop(cam_data, "clip_start", text="Start")
30 col.prop(cam_data, "clip_end", text="End")
32 layout.prop(cam_data, "type")
34 # DoF
35 col = layout.column(align=True)
36 col.prop(cam_data.dof, "use_dof")
37 if cam_data.dof.use_dof:
38 if rig["rig_id"].lower() in ("crane_rig", "dolly_rig"):
39 if cam_data.dof.focus_object is None:
40 col.operator("add_camera_rigs.add_dof_object",
41 text="Add DOF Empty", icon="OUTLINER_OB_EMPTY")
42 else:
43 col.prop(cam_data.dof, "focus_object")
44 row = col.row(align=True)
45 row.active = cam_data.dof.focus_object is None
46 row.prop(pose_bones["Camera"],
47 '["focus_distance"]', text="Focus Distance")
48 col.prop(pose_bones["Camera"],
49 '["aperture_fstop"]', text="F-Stop")
51 # Viewport display
52 layout.prop(active_object, 'show_in_front',
53 toggle=False, text='Show in Front')
54 layout.prop(cam_data, "show_limits")
55 col = layout.column(align=True)
56 col.prop(cam_data, "show_passepartout")
57 if cam_data.show_passepartout:
58 col.prop(cam_data, "passepartout_alpha")
60 # Composition guides
61 layout.popover(
62 panel="ADD_CAMERA_RIGS_PT_composition_guides",
63 text="Composition Guides",)
65 # Props and operators
66 col = layout.column(align=True)
67 col.prop(cam,
68 "hide_select", text="Make Camera Unselectable")
69 col.operator("add_camera_rigs.add_marker_bind",
70 text="Add Marker and Bind", icon="MARKER_HLT")
71 col.operator("add_camera_rigs.set_scene_camera",
72 text="Make Camera Active", icon='CAMERA_DATA')
74 if rig["rig_id"].lower() in ("dolly_rig", "crane_rig"):
75 # Track to Constraint
76 col = layout.column(align=True)
77 col.label(text="Tracking:")
78 col.prop(pose_bones["Camera"].constraints["Track To"],
79 'influence', text="Aim Lock", slider=True)
81 # Crane arm stuff
82 if rig["rig_id"].lower() == "crane_rig":
83 col = layout.column(align=True)
84 col.label(text="Crane Arm:")
85 col.prop(pose_bones["Crane_height"],
86 'scale', index=1, text="Arm Height")
87 col.prop(pose_bones["Crane_arm"],
88 'scale', index=1, text="Arm Length")
90 # 2D rig stuff
91 elif rig["rig_id"].lower() == "2d_rig":
92 col = layout.column(align=True)
93 col.label(text="2D Rig:")
94 col.prop(pose_bones["Camera"], '["rotation_shift"]',
95 text="Rotation/Shift")
96 if cam.data.sensor_width != 36:
97 col.label(text="Please set Camera Sensor Width to 36", icon="ERROR")
100 def register():
101 bpy.utils.register_class(ADD_CAMERA_RIGS_PT_camera_rig_ui)
104 def unregister():
105 bpy.utils.unregister_class(ADD_CAMERA_RIGS_PT_camera_rig_ui)