Browse Source

Round boxes coordinates to integers after movement

Group box may get non-integer coordinates if, e.g. moved with scaled viewport.
When it happens, previously sharp lines between to draw between pixels,
while previously blurred lines may reversly get a sharp look.

When in scaled state, graphics still may be badly-antialiased though.
pull/170/head
Nikita Zlobin 8 years ago
parent
commit
33befe7738
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      src/patchcanvas.py

+ 5
- 0
src/patchcanvas.py View File

@@ -2469,6 +2469,11 @@ class CanvasBox(QGraphicsItem):
def mouseReleaseEvent(self, event): def mouseReleaseEvent(self, event):
if self.m_cursor_moving: if self.m_cursor_moving:
self.setCursor(QCursor(Qt.ArrowCursor)) self.setCursor(QCursor(Qt.ArrowCursor))

# Box with fractional coordinates has weird look, since graphics is drawen between pixels
# possible situation, when moved with scaled viewport.
self.setX(round(self.x()))
self.setY(round(self.y()))
self.m_mouse_down = False self.m_mouse_down = False
self.m_cursor_moving = False self.m_cursor_moving = False
QGraphicsItem.mouseReleaseEvent(self, event) QGraphicsItem.mouseReleaseEvent(self, event)


Loading…
Cancel
Save