| ... |
... |
@@ -110,7 +110,7 @@ def prepare_crop_area(self, path: str) -> None: |
|
110
|
110
|
self._crop_area.show()
|
|
111
|
111
|
|
|
112
|
112
|
def _on_load_clicked(self, _button: Gtk.Button) -> None:
|
|
113
|
|
- def _on_file_selected(path):
|
|
|
113
|
+ def _on_file_selected(path: str) -> None:
|
|
114
|
114
|
self.prepare_crop_area(path)
|
|
115
|
115
|
|
|
116
|
116
|
AvatarChooserDialog(_on_file_selected,
|
| ... |
... |
@@ -240,8 +240,8 @@ def set_pixbuf(self, pixbuf: GdkPixbuf.Pixbuf) -> None: |
|
240
|
240
|
|
|
241
|
241
|
self._crop.width = 2 * self._base_width
|
|
242
|
242
|
self._crop.height = 2 * self._base_height
|
|
243
|
|
- self._crop.x = abs((width - self._crop.width) / 2)
|
|
244
|
|
- self._crop.y = abs((height - self._crop.height) / 2)
|
|
|
243
|
+ self._crop.x = int(abs((width - self._crop.width) / 2))
|
|
|
244
|
+ self._crop.y = int(abs((height - self._crop.height) / 2))
|
|
245
|
245
|
|
|
246
|
246
|
self._scale = 0.0
|
|
247
|
247
|
self._image.x = 0
|
| ... |
... |
@@ -570,10 +570,10 @@ def _on_motion_notify(self, |
|
570
|
570
|
top = self._crop.y
|
|
571
|
571
|
bottom = self._crop.y + self._crop.height - 1
|
|
572
|
572
|
|
|
573
|
|
- self._crop.x = left
|
|
574
|
|
- self._crop.y = top
|
|
575
|
|
- self._crop.width = right - left + 1
|
|
576
|
|
- self._crop.height = bottom - top + 1
|
|
|
573
|
+ self._crop.x = int(left)
|
|
|
574
|
+ self._crop.y = int(top)
|
|
|
575
|
+ self._crop.width = int(right - left + 1)
|
|
|
576
|
+ self._crop.height = int(bottom - top + 1)
|
|
577
|
577
|
|
|
578
|
578
|
damage = self._crop_to_widget()
|
|
579
|
579
|
self.queue_draw_area(
|
| ... |
... |
@@ -590,8 +590,8 @@ def _update_pixbufs(self) -> None: |
|
590
|
590
|
if scale * width > allocation.width:
|
|
591
|
591
|
scale = allocation.width / float(width)
|
|
592
|
592
|
|
|
593
|
|
- dest_width = width * scale
|
|
594
|
|
- dest_height = height * scale
|
|
|
593
|
+ dest_width = int(width * scale)
|
|
|
594
|
+ dest_height = int(height * scale)
|
|
595
|
595
|
|
|
596
|
596
|
if (self._pixbuf is None or
|
|
597
|
597
|
self._pixbuf.get_width != allocation.width or
|
| ... |
... |
@@ -628,25 +628,25 @@ def _update_pixbufs(self) -> None: |
|
628
|
628
|
(dest_height / self._base_height)))
|
|
629
|
629
|
crop_scale = float(min(scale_to_80, scale_to_image))
|
|
630
|
630
|
|
|
631
|
|
- self._crop.width = crop_scale * self._base_width / scale
|
|
632
|
|
- self._crop.height = crop_scale * self._base_height / scale
|
|
633
|
|
- self._crop.x = (
|
|
634
|
|
- self._browse_pixbuf.get_width() - self._crop.width) / 2
|
|
635
|
|
- self._crop.y = (
|
|
636
|
|
- self._browse_pixbuf.get_height() - self._crop.height) / 2
|
|
|
631
|
+ self._crop.width = int(crop_scale * self._base_width / scale)
|
|
|
632
|
+ self._crop.height = int(crop_scale * self._base_height / scale)
|
|
|
633
|
+ self._crop.x = int((
|
|
|
634
|
+ self._browse_pixbuf.get_width() - self._crop.width) / 2)
|
|
|
635
|
+ self._crop.y = int((
|
|
|
636
|
+ self._browse_pixbuf.get_height() - self._crop.height) / 2)
|
|
637
|
637
|
|
|
638
|
638
|
self._scale = scale
|
|
639
|
|
- self._image.x = (allocation.width - dest_width) / 2
|
|
640
|
|
- self._image.y = (allocation.height - dest_height) / 2
|
|
|
639
|
+ self._image.x = int((allocation.width - dest_width) / 2)
|
|
|
640
|
+ self._image.y = int((allocation.height - dest_height) / 2)
|
|
641
|
641
|
self._image.width = dest_width
|
|
642
|
642
|
self._image.height = dest_height
|
|
643
|
643
|
|
|
644
|
644
|
def _crop_to_widget(self) -> Gdk.Rectangle:
|
|
645
|
645
|
crop = Gdk.Rectangle()
|
|
646
|
|
- crop.x = self._image.x + self._crop.x * self._scale
|
|
647
|
|
- crop.y = self._image.y + self._crop.y * self._scale
|
|
648
|
|
- crop.width = self._crop.width * self._scale
|
|
649
|
|
- crop.height = self._crop.height * self._scale
|
|
|
646
|
+ crop.x = int(self._image.x + self._crop.x * self._scale)
|
|
|
647
|
+ crop.y = int(self._image.y + self._crop.y * self._scale)
|
|
|
648
|
+ crop.width = int(self._crop.width * self._scale)
|
|
|
649
|
+ crop.height = int(self._crop.height * self._scale)
|
|
650
|
650
|
return crop
|
|
651
|
651
|
|
|
652
|
652
|
def _update_cursor(self, x_coord: float, y_coord: float) -> None:
|