Skip to content

Commit bff3ff0

Browse files
authored
Merge pull request #1571 from Capsize-Games/develop
fix active grid area alignment
2 parents 40d96f3 + 5bd7f80 commit bff3ff0

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/airunner/gui/widgets/canvas/draggables/active_grid_area.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from PIL.ImageQt import QImage
44

5-
from PySide6.QtCore import QRect, QPoint, QPointF
5+
from PySide6.QtCore import QRect, QPointF
66
from PySide6.QtGui import QBrush, QColor, QPen, QPixmap, QPainter, Qt
77
from PySide6.QtWidgets import QGraphicsItem
88

@@ -217,10 +217,6 @@ def mouseReleaseEvent(self, event):
217217

218218
# Emit signal if we moved
219219
if has_moved:
220-
self.api.art.canvas.generate_mask()
221-
self.api.art.active_grid_area_updated()
222-
223-
# Save the snapped absolute position
224220
if (
225221
int(self._current_snapped_pos[0])
226222
!= self.active_grid_settings.pos_x
@@ -235,6 +231,31 @@ def mouseReleaseEvent(self, event):
235231
"pos_y", int(self._current_snapped_pos[1])
236232
)
237233

234+
# Update the in-memory settings object immediately
235+
self.active_grid_settings.pos_x = int(
236+
self._current_snapped_pos[0]
237+
)
238+
self.active_grid_settings.pos_y = int(
239+
self._current_snapped_pos[1]
240+
)
241+
242+
# Update the visual position to match the new settings
243+
try:
244+
view = self.scene().views()[0]
245+
canvas_offset = view.canvas_offset
246+
except (AttributeError, IndexError):
247+
canvas_offset = QPointF(0, 0)
248+
display_x = (
249+
int(self._current_snapped_pos[0]) - canvas_offset.x()
250+
)
251+
display_y = (
252+
int(self._current_snapped_pos[1]) - canvas_offset.y()
253+
)
254+
self.setPos(display_x, display_y)
255+
256+
self.api.art.canvas.generate_mask()
257+
self.api.art.active_grid_area_updated()
258+
238259
# Accept the event
239260
event.accept()
240261
else:

0 commit comments

Comments
 (0)