-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Preferences.py
72 lines (59 loc) · 2.34 KB
/
Preferences.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import bpy
from bpy.props import (
BoolProperty,
FloatProperty,
)
from bpy.types import AddonPreferences
def update_node_keymap(self, context):
wm = context.window_manager
active_kc = wm.keyconfigs.active
for key in active_kc.keymaps["Node Editor"].keymap_items:
if key.idname == "wm.call_menu" and key.type == "RIGHTMOUSE":
key.active = not key.active
addon_kc = wm.keyconfigs.addon
for key in addon_kc.keymaps["Node Editor"].keymap_items:
if key.idname == "rmn.right_mouse_navigation" and key.type == "RIGHTMOUSE":
key.active = not key.active
class RightMouseNavigationPreferences(AddonPreferences):
bl_idname = __package__
time: FloatProperty(
name="Time Threshold",
description="How long you have hold right mouse to open menu",
default=1.0,
min=0.1,
max=10,
)
reset_cursor_on_exit: BoolProperty(
name="Reset Cursor on Exit",
description="After exiting navigation, this determines if the cursor stays "
"where RMB was clicked (if unchecked) or resets to the center (if checked)",
default=False,
)
return_to_ortho_on_exit: BoolProperty(
name="Return to Orthographic on Exit",
description="After exiting navigation, this determines if the Viewport "
"returns to Orthographic view (if checked) or remains in Perspective view (if unchecked)",
default=True,
)
enable_for_node_editors: BoolProperty(
name="Enable for Node Editors",
description="Right Mouse will pan the view / open the Node Add/Search Menu",
default=False,
update=update_node_keymap,
)
def draw(self, context):
layout = self.layout
box = layout.box()
box.label(text="Menu / Movement", icon="DRIVER_DISTANCE")
box.prop(self, "time")
row = layout.row()
box = row.box()
box.label(text="Cursor", icon="ORIENTATION_CURSOR")
box.prop(self, "reset_cursor_on_exit")
box = row.box()
box.label(text="Node Editor", icon="NODETREE")
box.prop(self, "enable_for_node_editors")
row = layout.row()
box = row.box()
box.label(text="View", icon="VIEW3D")
box.prop(self, "return_to_ortho_on_exit")