Transform: Custom modifier to navigate while transforming

Discussed in #114646.

This commit transforms the "alt_navigation" option of the transform
operators into a new modal key item. "PASSTHROUGH_NAVIGATE"

In addition to cleaning up a lot of the code, it allows you to
customize the key chosen to navigate while transforming.
This commit is contained in:
Germano Cavalcante 2023-11-09 21:32:16 -03:00
parent 8eb5223663
commit 78943edc5d
13 changed files with 139 additions and 152 deletions

View File

@ -17,6 +17,12 @@ def keyconfig_update(keyconfig_data, keyconfig_version):
# Only copy once.
has_copy = False
def get_transform_modal_map():
for km_name, _km_parms, km_items_data in keyconfig_data:
if km_name == "Transform Modal Map":
return km_items_data
print("not found")
# Default repeat to false.
if keyconfig_version <= (2, 92, 0):
if not has_copy:
@ -69,18 +75,16 @@ def keyconfig_update(keyconfig_data, keyconfig_version):
keyconfig_data = copy.deepcopy(keyconfig_data)
has_copy = True
for km_name, _km_parms, km_items_data in keyconfig_data:
if km_name == "Transform Modal Map":
km_items = km_items_data["items"]
for (item_modal, item_event, _item_prop) in km_items:
if item_modal == 'TRANSLATE':
km_items.append(('VERT_EDGE_SLIDE', item_event, None))
elif item_modal == 'ROTATE':
km_items.append(('TRACKBALL', item_event, None))
if km_items_data := get_transform_modal_map():
km_items = km_items_data["items"]
for (item_modal, item_event, _item_prop) in km_items:
if item_modal == 'TRANSLATE':
km_items.append(('VERT_EDGE_SLIDE', item_event, None))
elif item_modal == 'ROTATE':
km_items.append(('TRACKBALL', item_event, None))
# The modal key for "Rotate Normals" also didn't exist until then.
km_items.append(('ROTATE_NORMALS', {"type": 'N', "value": 'PRESS'}, None))
break
# The modal key for "Rotate Normals" also didn't exist until then.
km_items.append(('ROTATE_NORMALS', {"type": 'N', "value": 'PRESS'}, None))
if keyconfig_version <= (4, 0, 3):
if not has_copy:
@ -88,10 +92,32 @@ def keyconfig_update(keyconfig_data, keyconfig_version):
has_copy = True
# "Snap Source Toggle" did not exist until then.
for km_name, _km_parms, km_items_data in keyconfig_data:
if km_name == "Transform Modal Map":
km_items_data["items"].append(("EDIT_SNAP_SOURCE_ON", {"type": 'B', "value": 'PRESS'}, None))
km_items_data["items"].append(("EDIT_SNAP_SOURCE_OFF", {"type": 'B', "value": 'PRESS'}, None))
break
if km_items_data := get_transform_modal_map():
km_items_data["items"].append(("EDIT_SNAP_SOURCE_ON", {"type": 'B', "value": 'PRESS'}, None))
km_items_data["items"].append(("EDIT_SNAP_SOURCE_OFF", {"type": 'B', "value": 'PRESS'}, None))
if keyconfig_version <= (4, 1, 5):
if km_items_data := get_transform_modal_map():
def use_alt_navigate():
km_item = next((i for i in km_items_data["items"] if i[0] ==
"PROPORTIONAL_SIZE" and i[1]["type"] == 'TRACKPADPAN'), None)
if km_item:
return "alt" not in km_item[1] or km_item[1]["alt"] is False
# Fallback.
import bpy
return getattr(
bpy.context.window_manager.keyconfigs.active.preferences,
"use_alt_navigation",
False)
if use_alt_navigate():
if not has_copy:
keyconfig_data = copy.deepcopy(keyconfig_data)
has_copy = True
km_items_data = get_transform_modal_map()
km_items_data["items"].append(
("PASSTHROUGH_NAVIGATE", {"type": 'LEFT_ALT', "value": 'ANY', "any": True}, None))
return keyconfig_data

View File

@ -359,16 +359,13 @@ def _template_items_transform_actions(
items = [
("transform.translate", {"type": params.select_mouse, "value": 'CLICK_DRAG'}, None),
op_tool_optional(
("transform.translate", {"type": 'G', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.move"), params),
op_tool_optional(
("transform.rotate", {"type": 'R', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.rotate"), params),
op_tool_optional(
("transform.resize", {"type": 'S', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.scale"), params),
]
@ -3753,8 +3750,7 @@ def km_grease_pencil_stroke_edit_mode(params):
("gpencil.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
# Extrude and move selected points
op_tool_optional(
("gpencil.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("gpencil.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude"), params),
# Delete
op_menu("VIEW3D_MT_edit_gpencil_delete", {"type": 'X', "value": 'PRESS'}),
@ -4683,10 +4679,8 @@ def km_object_mode(params):
op_menu("VIEW3D_MT_add", {"type": 'A', "value": 'PRESS', "shift": True}),
op_menu("VIEW3D_MT_object_apply", {"type": 'A', "value": 'PRESS', "ctrl": True}),
op_menu("VIEW3D_MT_make_links", {"type": 'L', "value": 'PRESS', "ctrl": True}),
("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("object.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("object.duplicate_move_linked", {"type": 'D', "value": 'PRESS', "alt": True}, None),
("object.join", {"type": 'J', "value": 'PRESS', "ctrl": True}, None),
("wm.context_toggle", {"type": 'PERIOD', "value": 'PRESS', "ctrl": True},
{"properties": [("data_path", 'tool_settings.use_transform_data_origin')]}),
@ -4870,13 +4864,10 @@ def km_paint_curve(params):
("paintcurve.delete_point", {"type": 'DEL', "value": 'PRESS'}, None),
("paintcurve.draw", {"type": 'RET', "value": 'PRESS'}, None),
("paintcurve.draw", {"type": 'NUMPAD_ENTER', "value": 'PRESS'}, None),
("transform.translate", {"type": 'G', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("transform.translate", {"type": 'G', "value": 'PRESS'}, None),
("transform.translate", {"type": params.select_mouse, "value": 'CLICK_DRAG'}, None),
("transform.rotate", {"type": 'R', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("transform.resize", {"type": 'S', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("transform.rotate", {"type": 'R', "value": 'PRESS'}, None),
("transform.resize", {"type": 'S', "value": 'PRESS'}, None),
])
return keymap
@ -5613,8 +5604,7 @@ def km_edit_mesh(params):
("mesh.normals_make_consistent", {"type": 'N', "value": 'PRESS', "shift": True, "ctrl": True},
{"properties": [("inside", True)]}),
op_tool_optional(
("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'},
{"properties": [("alt_navigation", params.use_alt_navigation)]}),
("view3d.edit_mesh_extrude_move_normal", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude_region"), params),
op_menu("VIEW3D_MT_edit_mesh_extrude", {"type": 'E', "value": 'PRESS', "alt": True}),
("transform.edge_crease", {"type": 'E', "value": 'PRESS', "shift": True}, None),
@ -5631,13 +5621,11 @@ def km_edit_mesh(params):
# No tool is available for this.
("mesh.rip_move", {"type": 'V', "value": 'PRESS', "alt": True},
{"properties": [("MESH_OT_rip", [("use_fill", True)],)]}),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("mesh.rip_edge_move", {"type": 'D', "value": 'PRESS', "alt": True}, None),
op_menu("VIEW3D_MT_edit_mesh_merge", {"type": 'M', "value": 'PRESS'}),
op_menu("VIEW3D_MT_edit_mesh_split", {"type": 'M', "value": 'PRESS', "alt": True}),
("mesh.edge_face_add", {"type": 'F', "value": 'PRESS', "repeat": True}, None),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("mesh.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
op_menu("VIEW3D_MT_mesh_add", {"type": 'A', "value": 'PRESS', "shift": True}),
("mesh.separate", {"type": 'P', "value": 'PRESS'}, None),
("mesh.split", {"type": 'Y', "value": 'PRESS'}, None),
@ -5758,8 +5746,7 @@ def km_edit_armature(params):
("armature.dissolve", {"type": 'X', "value": 'PRESS', "ctrl": True}, None),
("armature.dissolve", {"type": 'DEL', "value": 'PRESS', "ctrl": True}, None),
op_tool_optional(
("armature.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("armature.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude"), params),
("armature.extrude_forked", {"type": 'E', "value": 'PRESS', "shift": True}, None),
("armature.click_extrude", {"type": params.action_mouse, "value": 'CLICK', "ctrl": True}, None),
@ -6024,8 +6011,7 @@ def km_edit_curve_legacy(params):
("curve.separate", {"type": 'P', "value": 'PRESS'}, None),
("curve.split", {"type": 'Y', "value": 'PRESS'}, None),
op_tool_optional(
("curve.extrude_move", {"type": 'E', "value": 'PRESS'},
{"properties": [("TRANSFORM_OT_translate", [("alt_navigation", params.use_alt_navigation)])]}),
("curve.extrude_move", {"type": 'E', "value": 'PRESS'}, None),
(op_tool_cycle, "builtin.extrude"), params),
("curve.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("curve.make_segment", {"type": 'F', "value": 'PRESS'}, None),
@ -6196,6 +6182,9 @@ def km_transform_modal_map(params):
("PRECISION", {"type": 'RIGHT_SHIFT', "value": 'ANY', "any": True}, None),
])
if params.use_alt_navigation:
items.append(("PASSTHROUGH_NAVIGATE", {"type": 'LEFT_ALT', "value": 'ANY', "any": True}, None))
return keymap

View File

@ -15,12 +15,6 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
bl_label = "Extrude Individual and Move"
bl_idname = "view3d.edit_mesh_extrude_individual_move"
alt_navigation: BoolProperty(
name="alt_navigation",
default=False,
description="Transform Navigation with Alt",
)
@classmethod
def poll(cls, context):
obj = context.active_object
@ -41,7 +35,6 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"release_confirm": False,
"alt_navigation": self.alt_navigation,
},
)
elif select_mode[2] and totface > 1:
@ -49,14 +42,12 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={
"release_confirm": False,
"alt_navigation": self.alt_navigation,
})
elif select_mode[1] and totedge >= 1:
bpy.ops.mesh.extrude_edges_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"release_confirm": False,
"alt_navigation": self.alt_navigation,
},
)
else:
@ -64,7 +55,6 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"release_confirm": False,
"alt_navigation": self.alt_navigation,
},
)
@ -87,19 +77,13 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
description="Dissolves adjacent faces and intersects new geometry",
)
alt_navigation: BoolProperty(
name="alt_navigation",
default=False,
description="Transform Navigation with Alt",
)
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.mode == 'EDIT')
@staticmethod
def extrude_region(context, use_vert_normals, dissolve_and_intersect, alt_navigation):
def extrude_region(context, use_vert_normals, dissolve_and_intersect):
mesh = context.object.data
totface = mesh.total_face_sel
@ -112,7 +96,6 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
'INVOKE_REGION_WIN',
TRANSFORM_OT_shrink_fatten={
"release_confirm": False,
"alt_navigation": alt_navigation,
},
)
elif dissolve_and_intersect:
@ -125,7 +108,6 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"release_confirm": False,
"alt_navigation": alt_navigation,
},
)
else:
@ -135,7 +117,6 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"release_confirm": False,
"alt_navigation": alt_navigation,
},
)
@ -150,14 +131,12 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
# "constraint_axis": (True, True, False),
"constraint_axis": (False, False, False),
"release_confirm": False,
"alt_navigation": alt_navigation,
})
else:
bpy.ops.mesh.extrude_region_move(
'INVOKE_REGION_WIN',
TRANSFORM_OT_translate={
"release_confirm": False,
"alt_navigation": alt_navigation,
},
)
@ -167,7 +146,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(
context, False, self.dissolve_and_intersect, self.alt_navigation)
context, False, self.dissolve_and_intersect)
def invoke(self, context, _event):
return self.execute(context)
@ -178,19 +157,13 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
bl_label = "Extrude and Move on Individual Normals"
bl_idname = "view3d.edit_mesh_extrude_move_shrink_fatten"
alt_navigation: BoolProperty(
name="alt_navigation",
default=False,
description="Transform Navigation with Alt",
)
@classmethod
def poll(cls, context):
obj = context.active_object
return (obj is not None and obj.mode == 'EDIT')
def execute(self, context):
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True, False, self.alt_navigation)
return VIEW3D_OT_edit_mesh_extrude_move.extrude_region(context, True, False)
def invoke(self, context, _event):
return self.execute(context)
@ -201,12 +174,6 @@ class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator):
bl_label = "Extrude Manifold Along Normals"
bl_idname = "view3d.edit_mesh_extrude_manifold_normal"
alt_navigation: BoolProperty(
name="alt_navigation",
default=False,
description="Transform Navigation with Alt",
)
@classmethod
def poll(cls, context):
obj = context.active_object
@ -222,7 +189,6 @@ class VIEW3D_OT_edit_mesh_extrude_manifold_normal(Operator):
"orient_type": 'NORMAL',
"constraint_axis": (False, False, True),
"release_confirm": False,
"alt_navigation": self.alt_navigation,
},
)
return {'FINISHED'}

View File

@ -1200,14 +1200,10 @@ class VIEW3D_MT_transform_base:
# TODO: get rid of the custom text strings?
def draw(self, context):
layout = self.layout
alt_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_alt_navigation",
False)
layout.operator("transform.translate").alt_navigation = alt_navigation
layout.operator("transform.rotate").alt_navigation = alt_navigation
layout.operator("transform.resize", text="Scale").alt_navigation = alt_navigation
layout.operator("transform.translate")
layout.operator("transform.rotate")
layout.operator("transform.resize", text="Scale")
layout.separator()
@ -1228,18 +1224,13 @@ class VIEW3D_MT_transform_base:
# Generic transform menu - geometry types
class VIEW3D_MT_transform(VIEW3D_MT_transform_base, Menu):
def draw(self, context):
alt_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_alt_navigation",
False)
# base menu
VIEW3D_MT_transform_base.draw(self, context)
# generic...
layout = self.layout
if context.mode == 'EDIT_MESH':
layout.operator("transform.shrink_fatten", text="Shrink/Fatten").alt_navigation = alt_navigation
layout.operator("transform.shrink_fatten", text="Shrink/Fatten")
layout.operator("transform.skin_resize")
elif context.mode in ['EDIT_CURVE', 'EDIT_GREASE_PENCIL', 'EDIT_CURVES']:
layout.operator("transform.transform", text="Radius").mode = 'CURVE_SHRINKFATTEN'
@ -1248,10 +1239,8 @@ class VIEW3D_MT_transform(VIEW3D_MT_transform_base, Menu):
layout.separator()
props = layout.operator("transform.translate", text="Move Texture Space")
props.texture_space = True
props.alt_navigation = alt_navigation
props = layout.operator("transform.resize", text="Scale Texture Space")
props.texture_space = True
props.alt_navigation = alt_navigation
# Object-specific extensions to Transform menu
@ -4480,11 +4469,6 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.operator("mesh.delete", text="Delete Edges").type = 'EDGE'
if is_face_mode:
alt_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_alt_navigation",
False)
col = row.column(align=True)
col.label(text="Face", icon='FACESEL')
@ -4496,11 +4480,11 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
col.separator()
col.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").alt_navigation = alt_navigation
text="Extrude Faces")
col.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").alt_navigation = alt_navigation
text="Extrude Faces Along Normals")
col.operator("mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.alt_navigation = alt_navigation
text="Extrude Individual Faces")
col.operator("mesh.inset")
col.operator("mesh.poke")
@ -4552,11 +4536,6 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
def draw(self, context):
from math import pi
alt_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_alt_navigation",
False)
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
@ -4566,22 +4545,22 @@ class VIEW3D_MT_edit_mesh_extrude(Menu):
if mesh.total_face_sel:
layout.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").alt_navigation = alt_navigation
text="Extrude Faces")
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").alt_navigation = alt_navigation
text="Extrude Faces Along Normals")
layout.operator(
"mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.alt_navigation = alt_navigation
text="Extrude Individual Faces")
layout.operator("view3d.edit_mesh_extrude_manifold_normal",
text="Extrude Manifold").alt_navigation = alt_navigation
text="Extrude Manifold")
if mesh.total_edge_sel and (select_mode[0] or select_mode[1]):
layout.operator("mesh.extrude_edges_move",
text="Extrude Edges").TRANSFORM_OT_translate.alt_navigation = alt_navigation
text="Extrude Edges")
if mesh.total_vert_sel and select_mode[0]:
layout.operator("mesh.extrude_vertices_move",
text="Extrude Vertices").TRANSFORM_OT_translate.alt_navigation = alt_navigation
text="Extrude Vertices")
layout.separator()
@ -4740,22 +4719,15 @@ class VIEW3D_MT_edit_mesh_faces(Menu):
bl_idname = "VIEW3D_MT_edit_mesh_faces"
def draw(self, context):
alt_navigation = getattr(
context.window_manager.keyconfigs.active.preferences,
"use_alt_navigation",
False)
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("view3d.edit_mesh_extrude_move_normal",
text="Extrude Faces").alt_navigation = alt_navigation
text="Extrude Faces")
layout.operator("view3d.edit_mesh_extrude_move_shrink_fatten",
text="Extrude Faces Along Normals").alt_navigation = alt_navigation
layout.operator(
"mesh.extrude_faces_move",
text="Extrude Individual Faces").TRANSFORM_OT_shrink_fatten.alt_navigation = alt_navigation
text="Extrude Faces Along Normals")
layout.operator("mesh.extrude_faces_move", text="Extrude Individual Faces")
layout.separator()

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 5
#define BLENDER_FILE_SUBVERSION 6
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -1825,6 +1825,8 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
}
/* 401 6 did not require any do_version here. */
/**
* Versioning code until next subversion bump goes here.
*

View File

@ -121,9 +121,8 @@ int BIF_countTransformOrientation(const bContext *C);
#define P_CURSOR_EDIT (1 << 16)
#define P_CLNOR_INVALIDATE (1 << 17)
#define P_VIEW2D_EDGE_PAN (1 << 18)
#define P_VIEW3D_ALT_NAVIGATION (1 << 19)
/* For properties performed when confirming the transformation. */
#define P_POST_TRANSFORM (1 << 20)
#define P_POST_TRANSFORM (1 << 19)
void Transform_Properties(wmOperatorType *ot, int flags);

View File

@ -50,6 +50,7 @@ struct rctf;
struct rcti;
struct wmEvent;
struct wmGizmo;
struct wmKeyMapItem;
struct wmWindow;
struct wmWindowManager;
@ -212,7 +213,7 @@ bool ED_view3d_depth_unproject_v3(const ARegion *region,
*
* \note modal map events can also be used in `ED_view3d_navigation_do`.
*/
ViewOpsData *ED_view3d_navigation_init(bContext *C, const bool use_alt_navigation);
ViewOpsData *ED_view3d_navigation_init(bContext *C, const wmKeyMapItem *kmi_merge);
bool ED_view3d_navigation_do(bContext *C,
ViewOpsData *vod,
const wmEvent *event,

View File

@ -404,7 +404,7 @@ struct ViewOpsData_Utility : ViewOpsData {
/* Used by #ED_view3d_navigation_do. */
bool is_modal_event;
ViewOpsData_Utility(bContext *C, const bool use_alt_navigation = false)
ViewOpsData_Utility(bContext *C, const wmKeyMapItem *kmi_merge = nullptr)
: ViewOpsData(), keymap_items(), is_modal_event(false)
{
this->init_context(C);
@ -427,9 +427,31 @@ struct ViewOpsData_Utility : ViewOpsData {
continue;
}
wmKeyMapItem *kmi_copy = WM_keymap_add_item_copy(&keymap_tmp, kmi);
if (use_alt_navigation) {
kmi_copy->alt = true;
wmKeyMapItem *kmi_cpy = WM_keymap_add_item_copy(&keymap_tmp, kmi);
if (kmi_merge) {
if (kmi_merge->shift == 1 || ELEM(kmi_merge->type, EVT_RIGHTSHIFTKEY, EVT_LEFTSHIFTKEY)) {
kmi_cpy->shift = 1;
}
if (kmi_merge->ctrl == 1 || ELEM(kmi_merge->type, EVT_LEFTCTRLKEY, EVT_RIGHTCTRLKEY)) {
kmi_cpy->ctrl = 1;
}
if (kmi_merge->alt == 1 || ELEM(kmi_merge->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) {
kmi_cpy->alt = 1;
}
if (kmi_merge->oskey == 1 || ELEM(kmi_merge->type, EVT_OSKEY)) {
kmi_cpy->oskey = 1;
}
if (!ELEM(kmi_merge->type,
EVT_LEFTCTRLKEY,
EVT_LEFTALTKEY,
EVT_RIGHTALTKEY,
EVT_RIGHTCTRLKEY,
EVT_RIGHTSHIFTKEY,
EVT_LEFTSHIFTKEY,
EVT_OSKEY))
{
kmi_cpy->keymodifier |= kmi_merge->type;
}
}
}
@ -1037,13 +1059,13 @@ static const ViewOpsType *view3d_navigation_type_from_idname(const char *idname)
/* Unlike `viewops_data_create`, `ED_view3d_navigation_init` creates a navigation context along
* with an array of `wmKeyMapItem`s used for navigation. */
ViewOpsData *ED_view3d_navigation_init(bContext *C, const bool use_alt_navigation)
ViewOpsData *ED_view3d_navigation_init(bContext *C, const wmKeyMapItem *kmi_merge)
{
if (!CTX_wm_region_view3d(C)) {
return nullptr;
}
return new ViewOpsData_Utility(C, use_alt_navigation);
return new ViewOpsData_Utility(C, kmi_merge);
}
bool ED_view3d_navigation_do(bContext *C,

View File

@ -709,6 +709,8 @@ static bool transform_modal_item_poll(const wmOperator *op, int value)
}
break;
}
case TFM_MODAL_PASSTHROUGH_NAVIGATE:
return t->vod != nullptr;
}
return true;
}
@ -763,6 +765,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
{TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
{TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""},
{TFM_MODAL_PASSTHROUGH_NAVIGATE, "PASSTHROUGH_NAVIGATE", 0, "Navigate", ""},
{0, nullptr, 0, nullptr, nullptr},
};

View File

@ -283,6 +283,8 @@ enum {
TFM_MODAL_EDIT_SNAP_SOURCE_ON = 34,
TFM_MODAL_EDIT_SNAP_SOURCE_OFF = 35,
TFM_MODAL_PASSTHROUGH_NAVIGATE = 36,
};
/** \} */

View File

@ -687,9 +687,20 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
TFM_EDGE_SLIDE,
TFM_VERT_SLIDE))
{
const bool use_alt_navigation = (prop = RNA_struct_find_property(op->ptr, "alt_navigation")) &&
RNA_property_boolean_get(op->ptr, prop);
t->vod = ED_view3d_navigation_init(C, use_alt_navigation);
wmWindowManager *wm = CTX_wm_manager(C);
wmKeyMap *keymap = WM_keymap_active(wm, op->type->modalkeymap);
const wmKeyMapItem *kmi_passthrough = nullptr;
LISTBASE_FOREACH (const wmKeyMapItem *, kmi, &keymap->items) {
if (kmi->flag & KMI_INACTIVE) {
continue;
}
if (kmi->propvalue == TFM_MODAL_PASSTHROUGH_NAVIGATE) {
kmi_passthrough = kmi;
break;
}
}
t->vod = ED_view3d_navigation_init(C, kmi_passthrough);
}
setTransformViewMatrices(t);

View File

@ -807,12 +807,6 @@ void Transform_Properties(wmOperatorType *ot, int flags)
RNA_def_property_flag(prop, PROP_HIDDEN);
}
if (flags & P_VIEW3D_ALT_NAVIGATION) {
prop = RNA_def_boolean(
ot->srna, "alt_navigation", false, "Transform Navigation with Alt", nullptr);
RNA_def_property_flag(prop, PROP_HIDDEN);
}
if (flags & P_POST_TRANSFORM) {
prop = RNA_def_boolean(ot->srna,
"use_automerge_and_split",
@ -847,7 +841,7 @@ static void TRANSFORM_OT_translate(wmOperatorType *ot)
Transform_Properties(ot,
P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP |
P_OPTIONS | P_GPENCIL_EDIT | P_CURSOR_EDIT | P_VIEW2D_EDGE_PAN |
P_VIEW3D_ALT_NAVIGATION | P_POST_TRANSFORM);
P_POST_TRANSFORM);
}
static void TRANSFORM_OT_resize(wmOperatorType *ot)
@ -886,7 +880,7 @@ static void TRANSFORM_OT_resize(wmOperatorType *ot)
Transform_Properties(ot,
P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP |
P_OPTIONS | P_GPENCIL_EDIT | P_CENTER | P_VIEW3D_ALT_NAVIGATION);
P_OPTIONS | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_skin_resize(wmOperatorType *ot)
@ -963,7 +957,7 @@ static void TRANSFORM_OT_rotate(wmOperatorType *ot)
Transform_Properties(ot,
P_ORIENT_AXIS | P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR |
P_GEO_SNAP | P_GPENCIL_EDIT | P_CENTER | P_VIEW3D_ALT_NAVIGATION);
P_GEO_SNAP | P_GPENCIL_EDIT | P_CENTER);
}
static void TRANSFORM_OT_tilt(wmOperatorType *ot)
@ -1102,7 +1096,7 @@ static void TRANSFORM_OT_shrink_fatten(wmOperatorType *ot)
WM_operatortype_props_advanced_begin(ot);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_VIEW3D_ALT_NAVIGATION);
Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
}
static void TRANSFORM_OT_tosphere(wmOperatorType *ot)
@ -1208,7 +1202,7 @@ static void TRANSFORM_OT_edge_slide(wmOperatorType *ot)
"When Even mode is active, flips between the two adjacent edge loops");
RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp", "Clamp within the edge extents");
Transform_Properties(ot, P_MIRROR | P_GEO_SNAP | P_CORRECT_UV | P_VIEW3D_ALT_NAVIGATION);
Transform_Properties(ot, P_MIRROR | P_GEO_SNAP | P_CORRECT_UV);
}
static void TRANSFORM_OT_vert_slide(wmOperatorType *ot)
@ -1243,7 +1237,7 @@ static void TRANSFORM_OT_vert_slide(wmOperatorType *ot)
"When Even mode is active, flips between the two adjacent edge loops");
RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp", "Clamp within the edge extents");
Transform_Properties(ot, P_MIRROR | P_GEO_SNAP | P_CORRECT_UV | P_VIEW3D_ALT_NAVIGATION);
Transform_Properties(ot, P_MIRROR | P_GEO_SNAP | P_CORRECT_UV);
}
static void TRANSFORM_OT_edge_crease(wmOperatorType *ot)
@ -1391,8 +1385,8 @@ static void TRANSFORM_OT_transform(wmOperatorType *ot)
Transform_Properties(ot,
P_ORIENT_AXIS | P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR |
P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER | P_VIEW3D_ALT_NAVIGATION |
P_POST_TRANSFORM | P_OPTIONS);
P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER | P_POST_TRANSFORM |
P_OPTIONS);
}
static int transform_from_gizmo_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event)