|
6 | 6 | ) |
7 | 7 | from bpy.types import AddonPreferences |
8 | 8 |
|
| 9 | +menumodes = [] |
| 10 | +panelmodes = [] |
9 | 11 |
|
10 | 12 | def draw_cam_lock(self, context): |
11 | 13 | preferences = context.preferences |
@@ -64,6 +66,14 @@ def update_node_keymap(self, context): |
64 | 66 | key.active = addon_prefs.enable_for_node_editors |
65 | 67 |
|
66 | 68 |
|
| 69 | +def update_rebind_3dview_keymap(self, context): |
| 70 | + self.rebind_3dview_keymap(context, self.rmb_pan_rotate) |
| 71 | + |
| 72 | + |
| 73 | +def update_rebind_switch_nav_rotate(self, context): |
| 74 | + self.rebind_switch_nav_rotate(context, self.rmb_rotate_switch) |
| 75 | + |
| 76 | + |
67 | 77 | class RightMouseNavigationPreferences(AddonPreferences): |
68 | 78 | bl_idname = __package__ |
69 | 79 |
|
@@ -118,7 +128,151 @@ class RightMouseNavigationPreferences(AddonPreferences): |
118 | 128 | default=False, |
119 | 129 | update=cam_lock_update, |
120 | 130 | ) |
| 131 | + |
| 132 | + rmb_pan_rotate: BoolProperty( |
| 133 | + name="Switch MMB and RMB Drag Camera Navigation", |
| 134 | + description="Switches Camera Navigation controls to Right Mouse Button.", |
| 135 | + default=False, |
| 136 | + update=update_rebind_3dview_keymap, |
| 137 | + ) |
121 | 138 |
|
| 139 | + rmb_rotate_switch: BoolProperty( |
| 140 | + name="Use Alt to enter Right Mouse Navigation with WASD", |
| 141 | + description="Switches RMB Navigation and drag Rotation controls with Alt modifier.", |
| 142 | + default=False, |
| 143 | + update=update_rebind_switch_nav_rotate, |
| 144 | + ) |
| 145 | + |
| 146 | + |
| 147 | + def rebind_3dview_keymap(self, context, isActive): |
| 148 | + wm = context.window_manager |
| 149 | + active_kc = wm.keyconfigs.active |
| 150 | + addon_kc = wm.keyconfigs.addon |
| 151 | + |
| 152 | + if (isActive): |
| 153 | + for key in active_kc.keymaps["3D View"].keymap_items: |
| 154 | + if (key.idname == "view3d.cursor3d" and key.type == "RIGHTMOUSE"): |
| 155 | + key.type = "MIDDLEMOUSE" |
| 156 | + key.value = "CLICK" |
| 157 | + key.shift = True |
| 158 | + if (key.idname == "view3d.rotate" and key.type == "MIDDLEMOUSE"): |
| 159 | + key.type = "RIGHTMOUSE" |
| 160 | + key.value = "CLICK_DRAG" |
| 161 | + key.alt = True |
| 162 | + if (key.idname == "view3d.move" and key.type == "MIDDLEMOUSE"): |
| 163 | + key.type = "RIGHTMOUSE" |
| 164 | + key.value = "CLICK_DRAG" |
| 165 | + key.shift = True |
| 166 | + if (key.idname == "view3d.zoom" and key.type == "MIDDLEMOUSE"): |
| 167 | + key.type = "RIGHTMOUSE" |
| 168 | + key.value = "CLICK_DRAG" |
| 169 | + key.ctrl = True |
| 170 | + if (key.idname == "view3d.dolly" and key.type == "MIDDLEMOUSE"): |
| 171 | + key.type = "RIGHTMOUSE" |
| 172 | + key.value = "CLICK_DRAG" |
| 173 | + key.shift = True |
| 174 | + key.ctrl = True |
| 175 | + if (key.idname == "view3d.select_lasso" and key.type == "RIGHTMOUSE" and key.ctrl == True): |
| 176 | + key.type = "MIDDLEMOUSE" |
| 177 | + key.value = "CLICK_DRAG" |
| 178 | + key.ctrl = True |
| 179 | + if (key.idname == "view3d.select_lasso" and key.type == "RIGHTMOUSE" and key.ctrl == True and key.shift == True): |
| 180 | + key.type = "MIDDLEMOUSE" |
| 181 | + key.value = "CLICK_DRAG" |
| 182 | + key.shift = True |
| 183 | + key.ctrl = True |
| 184 | + if (key.idname == "transform.translate" and key.type == "RIGHTMOUSE"): |
| 185 | + key.type = "MIDDLEMOUSE" |
| 186 | + else: |
| 187 | + for key in active_kc.keymaps["3D View"].keymap_items: |
| 188 | + if (key.idname == "view3d.cursor3d" and key.type == "MIDDLEMOUSE"): |
| 189 | + key.type = "RIGHTMOUSE" |
| 190 | + key.value = "CLICK" |
| 191 | + key.shift = True |
| 192 | + if (key.idname == "view3d.rotate" and key.type == "RIGHTMOUSE"): |
| 193 | + key.type = "MIDDLEMOUSE" |
| 194 | + key.value = "PRESS" |
| 195 | + key.alt = False |
| 196 | + if (key.idname == "view3d.move" and key.type == "RIGHTMOUSE"): |
| 197 | + key.type = "MIDDLEMOUSE" |
| 198 | + key.value = "PRESS" |
| 199 | + key.shift = True |
| 200 | + if (key.idname == "view3d.zoom" and key.type == "RIGHTMOUSE"): |
| 201 | + key.type = "MIDDLEMOUSE" |
| 202 | + key.value = "PRESS" |
| 203 | + key.ctrl = True |
| 204 | + if (key.idname == "view3d.dolly" and key.type == "RIGHTMOUSE"): |
| 205 | + key.type = "MIDDLEMOUSE" |
| 206 | + key.value = "PRESS" |
| 207 | + key.shift = True |
| 208 | + key.ctrl = True |
| 209 | + if (key.idname == "view3d.select_lasso" and key.type == "MIDDLEMOUSE" and key.ctrl == True): |
| 210 | + key.type = "RIGHTMOUSE" |
| 211 | + key.value = "CLICK_DRAG" |
| 212 | + key.ctrl = True |
| 213 | + if (key.idname == "view3d.select_lasso" and key.type == "MIDDLEMOUSE" and key.ctrl == True and key.shift == True): |
| 214 | + key.type = "RIGHTMOUSE" |
| 215 | + key.value = "CLICK_DRAG" |
| 216 | + key.shift = True |
| 217 | + key.ctrl = True |
| 218 | + if (key.idname == "transform.translate" and key.type == "MIDDLEMOUSE"): |
| 219 | + key.type = "RIGHTMOUSE" |
| 220 | + |
| 221 | + |
| 222 | + def rebind_switch_nav_rotate(self, context, isActive): |
| 223 | + wm = context.window_manager |
| 224 | + active_kc = wm.keyconfigs.active |
| 225 | + addon_kc = wm.keyconfigs.addon |
| 226 | + |
| 227 | + if (isActive): |
| 228 | + for key in addon_kc.keymaps["3D View"].keymap_items: |
| 229 | + if (key.idname == "rmn.right_mouse_navigation"): |
| 230 | + key.type = "RIGHTMOUSE" |
| 231 | + key.value = "PRESS" |
| 232 | + key.alt = True |
| 233 | + for key in active_kc.keymaps["3D View"].keymap_items: |
| 234 | + if (key.idname == "view3d.rotate" and key.type == "RIGHTMOUSE"): |
| 235 | + key.type = "RIGHTMOUSE" |
| 236 | + key.value = "CLICK_DRAG" |
| 237 | + key.alt = False |
| 238 | + for i in menumodes: |
| 239 | + for key in active_kc.keymaps[i].keymap_items: |
| 240 | + if ( |
| 241 | + key.idname == "wm.call_menu" |
| 242 | + and key.type == "RIGHTMOUSE" |
| 243 | + ): |
| 244 | + key.active = True |
| 245 | + key.value = "CLICK" |
| 246 | + for i in panelmodes: |
| 247 | + for key in active_kc.keymaps[i].keymap_items: |
| 248 | + if key.idname == "wm.call_panel" and key.type == "RIGHTMOUSE" and key.active: |
| 249 | + key.active = False |
| 250 | + key.value = "CLICK" |
| 251 | + else: |
| 252 | + for key in addon_kc.keymaps["3D View"].keymap_items: |
| 253 | + if (key.idname == "rmn.right_mouse_navigation"): |
| 254 | + key.type = "RIGHTMOUSE" |
| 255 | + key.value = "PRESS" |
| 256 | + key.alt = False |
| 257 | + for key in active_kc.keymaps["3D View"].keymap_items: |
| 258 | + if (key.idname == "view3d.rotate" and key.type == "RIGHTMOUSE"): |
| 259 | + key.type = "RIGHTMOUSE" |
| 260 | + key.value = "CLICK_DRAG" |
| 261 | + key.alt = True |
| 262 | + for i in menumodes: |
| 263 | + for key in active_kc.keymaps[i].keymap_items: |
| 264 | + if ( |
| 265 | + key.idname == "wm.call_menu" |
| 266 | + and key.type == "RIGHTMOUSE" |
| 267 | + ): |
| 268 | + key.active = False |
| 269 | + key.value = "PRESS" |
| 270 | + for i in panelmodes: |
| 271 | + for key in active_kc.keymaps[i].keymap_items: |
| 272 | + if key.idname == "wm.call_panel" and key.type == "RIGHTMOUSE": |
| 273 | + key.active = True |
| 274 | + key.value = "PRESS" |
| 275 | + |
122 | 276 | def draw(self, context): |
123 | 277 | layout = self.layout |
124 | 278 |
|
@@ -150,6 +304,31 @@ def draw(self, context): |
150 | 304 | row.prop(self, "disable_camera_navigation") |
151 | 305 | row.prop(self, "show_cam_lock_ui") |
152 | 306 |
|
| 307 | + row = layout.row() |
| 308 | + box = row.box() |
| 309 | + box.label(text="Right Mouse Button Pan, Zoom, and Rotate", icon="VIEW3D") |
| 310 | + box.label(text="RMB Menus will be set to Click when these options are toggled.") |
| 311 | + box.prop(self, "rmb_pan_rotate") |
| 312 | + if self.rmb_pan_rotate: |
| 313 | + if not self.rmb_rotate_switch: |
| 314 | + box.label(text="Hold RMB then WASD for Navigation Mode") |
| 315 | + box.label(text="Alt + Drag RMB to Rotate 3D View") |
| 316 | + box.label(text="Shift + Drag RMB to Pan 3D View") |
| 317 | + box.label(text="Ctrl + Drag RMB to Zoom 3D View") |
| 318 | + box.label(text="Ctrl + Shift + Drag RMB to Dolly Zoom 3D View") |
| 319 | + box.label(text="Other controls swapped") |
| 320 | + box.label(text="Shift + Click MMB to Set 3D Cursor") |
| 321 | + box.label(text="Shift + Drag MMB to Transform Translate") |
| 322 | + box.label(text="Ctrl + Drag MMB to Lasso Selection") |
| 323 | + box.label(text="Shift + Ctrl + Drag MMB to Lasso Deselection") |
| 324 | + if (self.rmb_pan_rotate): |
| 325 | + box.prop(self, "rmb_rotate_switch") |
| 326 | + if self.rmb_rotate_switch: |
| 327 | + box.label(text="Drag + RMB will now Rotate 3D View") |
| 328 | + box.label(text="Alt + RMB then WASD for Navigation Mode") |
| 329 | + elif (not self.rmb_pan_rotate and self.rmb_rotate_switch): |
| 330 | + self.rmb_rotate_switch = False |
| 331 | + |
153 | 332 | # Keymap Customization |
154 | 333 | import rna_keymap_ui |
155 | 334 |
|
|
0 commit comments