Files
blender-portable-repo/scripts/addons/RetopoFlow/addon_common/common/blender_preferences.py
T
2026-03-17 14:30:01 -06:00

62 lines
2.1 KiB
Python

'''
Copyright (C) 2023 CG Cookie
http://cgcookie.com
hello@cgcookie.com
Created by Jonathan Denning, Jonathan Williamson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
import bpy
def get_preferences(ctx=None):
return (ctx if ctx else bpy.context).preferences
def mouse_doubleclick():
# time/delay (in seconds) for a double click
return bpy.context.preferences.inputs.mouse_double_click_time / 1000
def mouse_drag():
# number of pixels to drag before tweak/drag event is triggered
return bpy.context.preferences.inputs.drag_threshold_mouse
def mouse_move():
# number of pixels to move before the cursor is considered to have moved
# (used for cycling selected items on successive clicks)
return bpy.context.preferences.inputs.move_threshold
def mouse_select():
# returns 'LEFT' if LMB is used for selection or 'RIGHT' if RMB is used for selection
user_keyconfigs = bpy.context.window_manager.keyconfigs.user
map_select_type = {'LEFTMOUSE': 'LEFT', 'RIGHTMOUSE': 'RIGHT'}
try:
select_type = user_keyconfigs.keymaps['3D View'].keymap_items['view3d.select'].type
return map_select_type[select_type]
except Exception as e:
if hasattr(mouse_select, 'reported'): return # already reported
mouse_select.reported = True
print('Addon Common: Exception caught in mouse_select')
print('NOTE: only reporting this once')
print(f'Exception: {e}')
return 'LEFT' # fallback to 'LEFT'