Add keymaps, specials menu and auto center view checkbox #3

Merged
dupoxy merged 10 commits from add-keymaps into main 2024-09-21 20:42:48 +02:00
Showing only changes of commit 46e9bbada8 - Show all commits

View File

@ -45,7 +45,7 @@ class C3DB_OT_restore(bpy.types.Operator):
return {'FINISHED'}
class C3DB_OT_restore_and_next(bpy.types.Operator):
"""Restore selected 3D Cursor and go to next in the list"""
"""Restore selected 3D Cursor and go to next one in the list"""
bl_idname = "c3db.restore_and_next"
bl_label = "Load & next"
bl_options = {'REGISTER', 'UNDO'}
@ -69,7 +69,7 @@ class C3DB_OT_restore_and_next(bpy.types.Operator):
return {'FINISHED'}
class C3DB_OT_restore_and_previous(bpy.types.Operator):
"""Restore selected 3D Cursor and go to previous in the list"""
"""Restore selected 3D Cursor and go to previous one in the list"""
bl_idname = "c3db.restore_and_previous"
bl_label = "Load & previous"
bl_options = {'REGISTER', 'UNDO'}
@ -178,20 +178,39 @@ class C3DB_PT_panel(bpy.types.Panel):
row.operator("c3db.restore_and_next")
row.operator("c3db.restore_and_previous")
classes = (C3DB_PG_properties, C3DB_UL_list, C3DB_OT_save, C3DB_OT_restore, C3DB_OT_restore_and_next, C3DB_OT_restore_and_previous, C3DB_OT_remove_from_list, C3DB_OT_move_up_list, C3DB_OT_move_down_list, C3DB_PT_panel)
addon_keymaps = []
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.Scene.C3DB_3Dcursors_collection = bpy.props.CollectionProperty(type=C3DB_PG_properties)
bpy.types.Scene.C3DB_3Dcursors_index = bpy.props.IntProperty()
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='3D View', space_type='VIEW_3D')
kmi = km.keymap_items.new(C3DB_OT_save.bl_idname, 'S', 'PRESS', ctrl=True, shift=True)
addon_keymaps.append((km, kmi))
kmi = km.keymap_items.new(C3DB_OT_restore_and_next.bl_idname, 'R', 'PRESS', ctrl=True, shift=True)
addon_keymaps.append((km, kmi))
kmi = km.keymap_items.new(C3DB_OT_restore_and_previous.bl_idname, 'R', 'PRESS', ctrl=True, shift=True, alt=True)
addon_keymaps.append((km, kmi))
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
del bpy.types.Scene.C3DB_3Dcursors_collection
del bpy.types.Scene.C3DB_3Dcursors_index
wm = bpy.context.window_manager
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
if __name__ == "__main__":
register()