GPencil Tools: Optimize Undo for Rotate Canvas

The `rotate canvas` feature now adds steps to the undo stack only in camera view.
This change prevents the unnecessary filling of the undo stack when used in free view, enhancing usability.
This commit is contained in:
Pullusb
2024-04-14 21:56:22 +02:00
parent 4c926a8614
commit f08ec1cc51
2 changed files with 5 additions and 3 deletions

View File

@ -6,7 +6,7 @@ bl_info = {
"name": "Grease Pencil Tools",
"description": "Extra tools for Grease Pencil",
"author": "Samuel Bernou, Antonio Vazquez, Daniel Martinez Lara, Matias Mendiola",
"version": (1, 8, 2),
"version": (1, 8, 3),
"blender": (3, 0, 0),
"location": "Sidebar > Grease Pencil > Grease Pencil Tools",
"warning": "",

View File

@ -68,7 +68,7 @@ def draw_callback_px(self, context):
class RC_OT_RotateCanvas(bpy.types.Operator):
bl_idname = 'view3d.rotate_canvas'
bl_label = 'Rotate Canvas'
bl_options = {"REGISTER", "UNDO"}
bl_options = {"REGISTER"}
def get_center_view(self, context, cam):
'''
@ -109,7 +109,9 @@ class RC_OT_RotateCanvas(bpy.types.Operator):
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
context.area.tag_redraw()
if self.in_cam:
self.cam.rotation_mode = self.org_rotation_mode
self.cam.rotation_mode = self.org_rotation_mode
# Undo step is only needed if used within camera
bpy.ops.ed.undo_push(message='Rotate Canvas')
return {'FINISHED'}