Gizmo: optional custom orientations for transform
This aims to resolve a conflict where some users want to keep keyboard axis setting global, even when the orientation is set to something else. Move/rotate/scale can optionally each have a separate orientation. Some UI changes will be made next.
This commit is contained in:
@@ -64,6 +64,17 @@ class _template_widget:
|
||||
props = tool.gizmo_group_properties("VIEW3D_GGT_xform_extrude")
|
||||
layout.prop(props, "axis_type", expand=True)
|
||||
|
||||
class TRANSFORM_GGT_gizmo:
|
||||
@staticmethod
|
||||
def draw_settings_with_index(context, layout, index):
|
||||
row = layout.row(align=True)
|
||||
scene = context.scene
|
||||
orientation_slot = scene.transform_orientation_slots[index]
|
||||
value = orientation_slot.use
|
||||
row.prop(orientation_slot, "use", text="", icon='LINKED' if value else 'UNLINKED')
|
||||
if not value:
|
||||
row.prop(orientation_slot, "type", text="")
|
||||
|
||||
|
||||
class _defs_view3d_generic:
|
||||
@ToolDef.from_fn
|
||||
@@ -202,6 +213,8 @@ class _defs_transform:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def translate():
|
||||
def draw_settings(context, layout, tool):
|
||||
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 1)
|
||||
return dict(
|
||||
text="Move",
|
||||
# cursor='SCROLL_XY',
|
||||
@@ -209,10 +222,13 @@ class _defs_transform:
|
||||
widget="TRANSFORM_GGT_gizmo",
|
||||
operator="transform.translate",
|
||||
keymap="3D View Tool: Move",
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def rotate():
|
||||
def draw_settings(context, layout, tool):
|
||||
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 2)
|
||||
return dict(
|
||||
text="Rotate",
|
||||
# cursor='SCROLL_XY',
|
||||
@@ -220,10 +236,13 @@ class _defs_transform:
|
||||
widget="TRANSFORM_GGT_gizmo",
|
||||
operator="transform.rotate",
|
||||
keymap="3D View Tool: Rotate",
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def scale():
|
||||
def draw_settings(context, layout, tool):
|
||||
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 3)
|
||||
return dict(
|
||||
text="Scale",
|
||||
# cursor='SCROLL_XY',
|
||||
@@ -231,15 +250,19 @@ class _defs_transform:
|
||||
widget="TRANSFORM_GGT_gizmo",
|
||||
operator="transform.resize",
|
||||
keymap="3D View Tool: Scale",
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def scale_cage():
|
||||
def draw_settings(context, layout, tool):
|
||||
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 3)
|
||||
return dict(
|
||||
text="Scale Cage",
|
||||
icon="ops.transform.resize.cage",
|
||||
widget="VIEW3D_GGT_xform_cage",
|
||||
operator="transform.resize",
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
@@ -252,6 +275,8 @@ class _defs_transform:
|
||||
props = tool.gizmo_group_properties("TRANSFORM_GGT_gizmo")
|
||||
layout.prop(props, "drag_action")
|
||||
|
||||
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 1)
|
||||
|
||||
return dict(
|
||||
text="Transform",
|
||||
description=(
|
||||
|
||||
@@ -121,16 +121,16 @@ class VIEW3D_HT_header(Header):
|
||||
|
||||
# Orientation
|
||||
if object_mode in {'OBJECT', 'EDIT', 'POSE', 'EDIT_GPENCIL'}:
|
||||
orientation = scene.transform_orientation
|
||||
current_orientation = scene.current_orientation
|
||||
orient_slot = scene.transform_orientation_slots[0]
|
||||
custom_orientation = orient_slot.custom_orientation
|
||||
|
||||
if not current_orientation:
|
||||
trans_orientation = bpy.types.Scene.bl_rna.properties["transform_orientation"].enum_items[orientation]
|
||||
trans_icon = getattr(trans_orientation, "icon", "BLANK1")
|
||||
if custom_orientation is None:
|
||||
trans_orientation = bpy.types.TransformOrientationSlot.bl_rna.properties["type"].enum_items[orient_slot.type]
|
||||
trans_icon = getattr(trans_orientation, "icon", 'BLANK1')
|
||||
trans_name = getattr(trans_orientation, "name", "Orientation")
|
||||
else:
|
||||
trans_icon = 'OBJECT_ORIGIN'
|
||||
trans_name = getattr(current_orientation, "name", "Orientation")
|
||||
trans_name = getattr(custom_orientation, "name", "Orientation")
|
||||
|
||||
row = layout.row(align=True)
|
||||
|
||||
@@ -5258,11 +5258,12 @@ class VIEW3D_PT_transform_orientations(Panel):
|
||||
layout.label(text="Transform Orientations")
|
||||
|
||||
scene = context.scene
|
||||
orientation = scene.current_orientation
|
||||
orient_slot = scene.transform_orientation_slots[0]
|
||||
orientation = orient_slot.custom_orientation
|
||||
|
||||
row = layout.row()
|
||||
col = row.column()
|
||||
col.prop(scene, "transform_orientation", expand=True)
|
||||
col.prop(orient_slot, "type", expand=True)
|
||||
row.operator("transform.create_orientation", text="", icon='ADD', emboss=False).use = True
|
||||
|
||||
if orientation:
|
||||
|
||||
Reference in New Issue
Block a user