From 0a29707c3cef73135f7e9a8ddb1893d3274d78e8 Mon Sep 17 00:00:00 2001 From: akaneyu Date: Sun, 23 Mar 2025 13:37:58 +0900 Subject: [PATCH] Fix: start position of the selection may be incorrect --- addon/app.py | 19 ++++++++++--------- addon/operators.py | 6 ++++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/addon/app.py b/addon/app.py index e1212a8..b764831 100644 --- a/addon/app.py +++ b/addon/app.py @@ -1,5 +1,5 @@ ''' - Copyright (C) 2021 - 2024 Akaneyu + Copyright (C) 2021 - 2025 Akaneyu 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 @@ -136,17 +136,18 @@ def draw_handler(): # release the selection if the image is changed if area_session.selection or area_session.selection_region: - if img != area_session.prev_image: - cancel_selection(context) + if area_session.prev_image: + if img != area_session.prev_image: + cancel_selection(context) - elif width != area_session.prev_image_width \ - or height != area_session.prev_image_height: + elif width != area_session.prev_image_width \ + or height != area_session.prev_image_height: - crop_selection(context) + crop_selection(context) - area_session.prev_image = img - area_session.prev_image_width = width - area_session.prev_image_height = height + area_session.prev_image = img + area_session.prev_image_width = width + area_session.prev_image_height = height if area_session.layer_moving \ or area_session.layer_rotating \ diff --git a/addon/operators.py b/addon/operators.py index 13b9339..a75cecb 100644 --- a/addon/operators.py +++ b/addon/operators.py @@ -45,12 +45,14 @@ class IMAGE_EDITOR_PLUS_OT_make_selection(bpy.types.Operator): if area_session.selection_region: area_session.selection_region[1] = region_pos - else: - area_session.selection_region = [region_pos, region_pos] elif event.type == 'LEFTMOUSE': if event.value == 'PRESS': self.lmb = True + + region_pos = [event.mouse_region_x, event.mouse_region_y] + area_session.selection_region = [region_pos, region_pos] + elif event.value == 'RELEASE': self.lmb = False