Add keymaps, specials menu and auto center view checkbox #3
39
__init__.py
39
__init__.py
@ -16,6 +16,8 @@ class C3DB_MT_menu_restore(bpy.types.Menu):
|
||||
layout = self.layout
|
||||
layout.operator("c3db.restore_next")
|
||||
layout.operator("c3db.restore_previous")
|
||||
layout.separator()
|
||||
layout.operator("c3db.delete_all")
|
||||
|
||||
|
||||
class C3DB_UL_list(bpy.types.UIList):
|
||||
@ -41,7 +43,7 @@ class C3DB_OT_save(bpy.types.Operator):
|
||||
context.scene.C3DB_3Dcursors_index = (
|
||||
len(context.scene.C3DB_3Dcursors_collection) - 1
|
||||
)
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -69,7 +71,7 @@ class C3DB_OT_restore(bpy.types.Operator):
|
||||
context.scene.cursor.rotation_euler = item.rotation
|
||||
if context.scene.c3db_auto_center_view_checkbox:
|
||||
bpy.ops.view3d.view_center_cursor()
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -104,7 +106,7 @@ class C3DB_OT_restore_next(bpy.types.Operator):
|
||||
context.scene.cursor.rotation_euler = item.rotation
|
||||
if context.scene.c3db_auto_center_view_checkbox:
|
||||
bpy.ops.view3d.view_center_cursor()
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -139,7 +141,20 @@ class C3DB_OT_restore_previous(bpy.types.Operator):
|
||||
context.scene.cursor.rotation_euler = item.rotation
|
||||
if context.scene.c3db_auto_center_view_checkbox:
|
||||
bpy.ops.view3d.view_center_cursor()
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class C3DB_OT_delete_all(bpy.types.Operator):
|
||||
"""Delete all 3D Cursors"""
|
||||
|
||||
bl_idname = "c3db.delete_all"
|
||||
bl_label = "Delete All 3D Cursors"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
def execute(self, context):
|
||||
context.scene.C3DB_3Dcursors_collection.clear()
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -169,7 +184,7 @@ class C3DB_OT_remove_from_list(bpy.types.Operator):
|
||||
context.scene.C3DB_3Dcursors_index = C3DB_3Dcursors_index
|
||||
elif C3DB_3Dcursors_collection:
|
||||
context.scene.C3DB_3Dcursors_index = len(C3DB_3Dcursors_collection) - 1
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -188,7 +203,7 @@ class C3DB_OT_move_up_list(bpy.types.Operator):
|
||||
collection = context.scene.C3DB_3Dcursors_collection
|
||||
collection.move(index, index - 1)
|
||||
context.scene.C3DB_3Dcursors_index -= 1
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -210,7 +225,7 @@ class C3DB_OT_move_down_list(bpy.types.Operator):
|
||||
collection = context.scene.C3DB_3Dcursors_collection
|
||||
collection.move(index, index + 1)
|
||||
context.scene.C3DB_3Dcursors_index += 1
|
||||
context.area.tag_redraw() # Add this line to refresh the UI
|
||||
context.area.tag_redraw() # Refresh the UI
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@ -262,6 +277,7 @@ classes = (
|
||||
C3DB_OT_restore,
|
||||
C3DB_OT_restore_next,
|
||||
C3DB_OT_restore_previous,
|
||||
C3DB_OT_delete_all,
|
||||
C3DB_OT_remove_from_list,
|
||||
C3DB_OT_move_up_list,
|
||||
C3DB_OT_move_down_list,
|
||||
@ -314,6 +330,15 @@ def register():
|
||||
)
|
||||
c3db_keymaps.append((km, kmi))
|
||||
|
||||
kmi = km.keymap_items.new(
|
||||
C3DB_OT_delete_all.bl_idname,
|
||||
"X",
|
||||
"PRESS",
|
||||
ctrl=True,
|
||||
shift=True,
|
||||
)
|
||||
c3db_keymaps.append((km, kmi))
|
||||
|
||||
|
||||
def unregister():
|
||||
for cls in classes:
|
||||
|
Loading…
Reference in New Issue
Block a user