Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
| Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | for item_container in items_all: | ||||
| # properties={"name": item.idname}, | # properties={"name": item.idname}, | ||||
| properties=kmi_hack_properties, | properties=kmi_hack_properties, | ||||
| include={'KEYBOARD'}, | include={'KEYBOARD'}, | ||||
| )[1] | )[1] | ||||
| if kmi_found is None: | if kmi_found is None: | ||||
| if item.data_block: | if item.data_block: | ||||
| # PAINT_OT_brush_select | # PAINT_OT_brush_select | ||||
| editor = context.area.type | |||||
campbellbarton: This is already accessible via `space_type`. | |||||
| mode = context.active_object.mode | mode = context.active_object.mode | ||||
| # See: BKE_paint_get_tool_prop_id_from_paintmode | # See: BKE_paint_get_tool_prop_id_from_paintmode | ||||
| if editor == 'IMAGE_EDITOR' and context.space_data.ui_mode == 'PAINT': | |||||
| attr = "image_tool" | |||||
| elif editor == 'VIEW_3D': | |||||
| attr = { | attr = { | ||||
| 'SCULPT': "sculpt_tool", | 'SCULPT': "sculpt_tool", | ||||
| 'VERTEX_PAINT': "vertex_tool", | 'VERTEX_PAINT': "vertex_tool", | ||||
| 'WEIGHT_PAINT': "weight_tool", | 'WEIGHT_PAINT': "weight_tool", | ||||
| 'TEXTURE_PAINT': "image_tool", | 'TEXTURE_PAINT': "image_tool", | ||||
| 'PAINT_GPENCIL': "gpencil_tool", | 'PAINT_GPENCIL': "gpencil_tool", | ||||
| 'VERTEX_GPENCIL': "gpencil_vertex_tool", | 'VERTEX_GPENCIL': "gpencil_vertex_tool", | ||||
| 'SCULPT_GPENCIL': "gpencil_sculpt_tool", | 'SCULPT_GPENCIL': "gpencil_sculpt_tool", | ||||
| 'WEIGHT_GPENCIL': "gpencil_weight_tool", | 'WEIGHT_GPENCIL': "gpencil_weight_tool", | ||||
| }.get(mode, None) | }.get(mode, None) | ||||
| else: | |||||
| attr = None | |||||
| if attr is not None: | if attr is not None: | ||||
| setattr(kmi_hack_brush_select_properties, attr, item.data_block) | setattr(kmi_hack_brush_select_properties, attr, item.data_block) | ||||
| kmi_found = wm.keyconfigs.find_item_from_operator( | kmi_found = wm.keyconfigs.find_item_from_operator( | ||||
| idname="paint.brush_select", | idname="paint.brush_select", | ||||
| context='INVOKE_REGION_WIN', | context='INVOKE_REGION_WIN', | ||||
| properties=kmi_hack_brush_select_properties, | properties=kmi_hack_brush_select_properties, | ||||
| include={'KEYBOARD'}, | include={'KEYBOARD'}, | ||||
| )[1] | )[1] | ||||
| elif mode in {'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: | elif mode in {'PARTICLE_EDIT', 'SCULPT_GPENCIL'}: | ||||
| # Doesn't use brushes | # Doesn't use brushes | ||||
| pass | pass | ||||
| else: | else: | ||||
| print("Unsupported mode:", mode) | print("Unsupported mode:", mode) | ||||
| del mode, attr | del editor, mode, attr | ||||
| else: | else: | ||||
| kmi_found = None | kmi_found = None | ||||
| if kmi_found is not None: | if kmi_found is not None: | ||||
| pass | pass | ||||
| elif item.operator is not None: | elif item.operator is not None: | ||||
| kmi_found = wm.keyconfigs.find_item_from_operator( | kmi_found = wm.keyconfigs.find_item_from_operator( | ||||
| ▲ Show 20 Lines • Show All 230 Lines • Show Last 20 Lines | |||||
This is already accessible via space_type.