Keymap: add option for tilde key preference
Since the view menu is redundant for people with a numpad, add a preference for it to switch between gizmos instead.
This commit is contained in:
parent
9c9081d9ef
commit
1f891bbc2c
Notes:
blender-bot
2023-02-14 07:39:46 +01:00
Referenced by issue #63739, Keymap option to configure Tilde Key for the 3D viewport
|
@ -32,7 +32,7 @@ class Prefs(bpy.types.KeyConfigPreferences):
|
|||
update=update_fn,
|
||||
)
|
||||
spacebar_action: EnumProperty(
|
||||
name="Spacebar",
|
||||
name="Spacebar Action",
|
||||
items=(
|
||||
('PLAY', "Play",
|
||||
"Toggle animation playback "
|
||||
|
@ -81,6 +81,23 @@ class Prefs(bpy.types.KeyConfigPreferences):
|
|||
default=False,
|
||||
update=update_fn,
|
||||
)
|
||||
v3d_tilde_action: EnumProperty(
|
||||
name="Tilde Action",
|
||||
items=(
|
||||
('VIEW', "Navigate",
|
||||
"View operations (useful for keyboards without a numpad)",
|
||||
0),
|
||||
('GIZMO', "Gizmos",
|
||||
"Control transform gizmos",
|
||||
1),
|
||||
),
|
||||
description=(
|
||||
"Action when 'Tilde' is pressed"
|
||||
),
|
||||
default='VIEW',
|
||||
update=update_fn,
|
||||
)
|
||||
|
||||
# Developer note, this is an experemental option.
|
||||
use_pie_click_drag: BoolProperty(
|
||||
name="Pie Menu on Drag",
|
||||
|
@ -113,6 +130,8 @@ class Prefs(bpy.types.KeyConfigPreferences):
|
|||
col.prop(self, "use_v3d_tab_menu")
|
||||
col.prop(self, "use_pie_click_drag")
|
||||
col = split.column()
|
||||
col.label(text="Tilde Action:")
|
||||
col.row().prop(self, "v3d_tilde_action", expand=True)
|
||||
col.prop(self, "use_v3d_shade_ex_pie")
|
||||
|
||||
|
||||
|
@ -133,6 +152,7 @@ def load():
|
|||
select_mouse=kc_prefs.select_mouse,
|
||||
use_mouse_emulate_3_button=prefs.inputs.use_mouse_emulate_3_button,
|
||||
spacebar_action=kc_prefs.spacebar_action,
|
||||
v3d_tilde_action=kc_prefs.v3d_tilde_action,
|
||||
use_select_all_toggle=kc_prefs.use_select_all_toggle,
|
||||
use_v3d_tab_menu=kc_prefs.use_v3d_tab_menu,
|
||||
use_v3d_shade_ex_pie=kc_prefs.use_v3d_shade_ex_pie,
|
||||
|
|
|
@ -50,6 +50,7 @@ class Params:
|
|||
"use_v3d_shade_ex_pie",
|
||||
# Experemental option.
|
||||
"use_pie_click_drag",
|
||||
"v3d_tilde_action",
|
||||
)
|
||||
|
||||
def __init__(
|
||||
|
@ -65,6 +66,7 @@ class Params:
|
|||
use_v3d_tab_menu=False,
|
||||
use_v3d_shade_ex_pie=False,
|
||||
use_pie_click_drag=False,
|
||||
v3d_tilde_action='VIEW',
|
||||
):
|
||||
from sys import platform
|
||||
self.apple = (platform == 'darwin')
|
||||
|
@ -109,6 +111,7 @@ class Params:
|
|||
self.use_select_all_toggle = use_select_all_toggle
|
||||
self.use_v3d_tab_menu = use_v3d_tab_menu
|
||||
self.use_v3d_shade_ex_pie = use_v3d_shade_ex_pie
|
||||
self.v3d_tilde_action = v3d_tilde_action
|
||||
|
||||
self.use_pie_click_drag = use_pie_click_drag
|
||||
if not use_pie_click_drag:
|
||||
|
@ -927,7 +930,10 @@ def km_view3d(params):
|
|||
{"properties": [("use_all_regions", True), ("center", False)]}),
|
||||
("view3d.view_all", {"type": 'C', "value": 'PRESS', "shift": True},
|
||||
{"properties": [("center", True)]}),
|
||||
op_menu_pie("VIEW3D_MT_view_pie", {"type": 'ACCENT_GRAVE', "value": params.pie_value}),
|
||||
op_menu_pie(
|
||||
"VIEW3D_MT_view_pie" if params.v3d_tilde_action == 'VIEW' else "VIEW3D_MT_transform_gizmo_pie",
|
||||
{"type": 'ACCENT_GRAVE', "value": params.pie_value},
|
||||
),
|
||||
*(() if not params.use_pie_click_drag else
|
||||
(("view3d.navigate", {"type": 'ACCENT_GRAVE', "value": 'CLICK'}, None),)),
|
||||
("view3d.navigate", {"type": 'ACCENT_GRAVE', "value": 'PRESS', "shift": True}, None),
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
from bpy.props import (
|
||||
BoolProperty,
|
||||
EnumProperty,
|
||||
)
|
||||
|
||||
|
||||
class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
|
||||
|
@ -138,8 +142,55 @@ class VIEW3D_OT_edit_mesh_extrude_shrink_fatten(Operator):
|
|||
return self.execute(context)
|
||||
|
||||
|
||||
class VIEW3D_OT_transform_gizmo_set(Operator):
|
||||
"""Set the current transform gizmo"""
|
||||
bl_label = "Transform Gizmo Set"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_idname = "view3d.transform_gizmo_set"
|
||||
|
||||
extend: BoolProperty(
|
||||
default=False,
|
||||
)
|
||||
type: EnumProperty(
|
||||
items=(
|
||||
('TRANSLATE', "Move", ""),
|
||||
('ROTATE', "Rotate", ""),
|
||||
('SCALE', "Scale", ""),
|
||||
),
|
||||
options={'ENUM_FLAG'},
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.area.type == 'VIEW_3D'
|
||||
|
||||
def execute(self, context):
|
||||
space_data = context.space_data
|
||||
space_data.show_gizmo = True
|
||||
attrs = ("show_gizmo_object_translate", "show_gizmo_object_rotate", "show_gizmo_object_scale")
|
||||
attr_t, attr_r, attr_s = attrs
|
||||
attr_active = tuple(
|
||||
attrs[('TRANSLATE', 'ROTATE', 'SCALE').index(t)]
|
||||
for t in self.type
|
||||
)
|
||||
if self.extend:
|
||||
for attr in attrs:
|
||||
if attr in attr_active:
|
||||
setattr(space_data, attr, True)
|
||||
else:
|
||||
for attr in attrs:
|
||||
setattr(space_data, attr, attr in attr_active)
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
if not self.properties.is_property_set("extend"):
|
||||
self.extend = event.shift
|
||||
return self.execute(context)
|
||||
|
||||
|
||||
classes = (
|
||||
VIEW3D_OT_edit_mesh_extrude_individual_move,
|
||||
VIEW3D_OT_edit_mesh_extrude_move,
|
||||
VIEW3D_OT_edit_mesh_extrude_shrink_fatten,
|
||||
VIEW3D_OT_transform_gizmo_set,
|
||||
)
|
||||
|
|
|
@ -4583,6 +4583,25 @@ class VIEW3D_MT_view_pie(Menu):
|
|||
pie.operator("view3d.view_selected", text="View Selected", icon='ZOOM_SELECTED')
|
||||
|
||||
|
||||
class VIEW3D_MT_transform_gizmo_pie(Menu):
|
||||
bl_label = "View"
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
pie = layout.menu_pie()
|
||||
# 1: Left
|
||||
pie.operator("view3d.transform_gizmo_set", text="Move").type = {'TRANSLATE'}
|
||||
# 2: Right
|
||||
pie.operator("view3d.transform_gizmo_set", text="Rotate").type = {'ROTATE'}
|
||||
# 3: Down
|
||||
pie.operator("view3d.transform_gizmo_set", text="Scale").type = {'SCALE'}
|
||||
# 4: Up
|
||||
pie.prop(context.space_data, "show_gizmo", text="Show Gizmos", icon='GIZMO')
|
||||
# 5: Up/Left
|
||||
pie.operator("view3d.transform_gizmo_set", text="All").type = {'TRANSLATE', 'ROTATE', 'SCALE'}
|
||||
|
||||
|
||||
class VIEW3D_MT_shading_pie(Menu):
|
||||
bl_label = "Shading"
|
||||
|
||||
|
@ -6528,6 +6547,7 @@ classes = (
|
|||
VIEW3D_MT_edit_gpencil_interpolate,
|
||||
VIEW3D_MT_object_mode_pie,
|
||||
VIEW3D_MT_view_pie,
|
||||
VIEW3D_MT_transform_gizmo_pie,
|
||||
VIEW3D_MT_shading_pie,
|
||||
VIEW3D_MT_shading_ex_pie,
|
||||
VIEW3D_MT_pivot_pie,
|
||||
|
|
Loading…
Reference in New Issue