Skip to content

Commit

Permalink
More reliable mouse cursor when cropping/scaling with zoom or hidpi
Browse files Browse the repository at this point in the history
issue #214
  • Loading branch information
maoschanz committed Sep 15, 2020
1 parent bc3dce2 commit a294793
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h3>Recommended method</h3>
<h3>Alternative methods for Ubuntu</h3>
<p>
<a href="https://launchpad.net/~cartes/+archive/ubuntu/drawing/">
PPA repository (version 0.4.13)
PPA repository (version 0.4.14)
</a>
</p>
<p>
Expand Down
13 changes: 13 additions & 0 deletions src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,19 @@ def get_corrected_coords(self, x1, x2, y1, y2, with_selection, with_zoom):
# the zoom is not 1.0
return x1, x2, y1, y2

def get_nineths_sizes(self, apply_to_selection):
"""Returns the sizes of the 'nineths' of the image used for example by
'scale' or 'crop' to decide the cursor they'll show."""
height = self.temp_pixbuf.get_height()
width = self.temp_pixbuf.get_width()
w_left, w_right, h_top, h_bottom = self.get_corrected_coords(0, width, \
0, height, apply_to_selection, True)
w_left += 0.4 * width * self.zoom_level
w_right -= 0.4 * width * self.zoom_level
h_top += 0.4 * height * self.zoom_level
h_bottom -= 0.4 * height * self.zoom_level
return w_left, w_right, h_top, h_bottom

def on_scroll_on_area(self, area, event):
# TODO https://lazka.github.io/pgi-docs/index.html#Gdk-3.0/classes/EventScroll.html#Gdk.EventScroll
ctrl_is_used = (event.state & Gdk.ModifierType.CONTROL_MASK) == Gdk.ModifierType.CONTROL_MASK
Expand Down
11 changes: 2 additions & 9 deletions src/tools/canvas_tools/abstract_canvas_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,8 @@ def get_handle_cursor_name(self, event_x, event_y):
"""Return the name of the accurate cursor for tools such as `scale` or
`crop`, with or without an active selection, depending on the size and
position of the resized/cropped area."""
height = self.get_image().temp_pixbuf.get_height()
width = self.get_image().temp_pixbuf.get_width()
w_left, w_right, h_top, h_bottom = self.get_image().get_corrected_coords(\
0, width, 0, height, self.apply_to_selection, True)
# Comment to help the debug:
h_top += 0.4 * height
h_bottom -= 0.4 * height
w_left += 0.4 * width
w_right -= 0.4 * width
w_left, w_right, h_top, h_bottom = self.get_image().get_nineths_sizes( \
self.apply_to_selection)
# print("get_handle_cursor_name", w_left, w_right, h_top, h_bottom)

cursor_name = ''
Expand Down

0 comments on commit a294793

Please sign in to comment.