Skip to content

Commit cd4c898

Browse files
committed
Add directional sizing cursors.
Tested on GTK, macOS, NbAgg, Qt, and Tk.
1 parent f0fb478 commit cd4c898

File tree

7 files changed

+16
-2
lines changed

7 files changed

+16
-2
lines changed

lib/matplotlib/backend_tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class Cursors(enum.IntEnum): # Must subclass int for the macOS backend.
3232
SELECT_REGION = enum.auto()
3333
MOVE = enum.auto()
3434
WAIT = enum.auto()
35+
RESIZE_HORIZONTAL = enum.auto()
36+
RESIZE_VERTICAL = enum.auto()
3537
cursors = Cursors # Backcompat.
3638

3739
# Views positions tool

lib/matplotlib/backends/_backend_tk.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
cursors.POINTER: "arrow",
3535
cursors.SELECT_REGION: "tcross",
3636
cursors.WAIT: "watch",
37-
}
37+
cursors.RESIZE_HORIZONTAL: "sb_h_double_arrow",
38+
cursors.RESIZE_VERTICAL: "sb_v_double_arrow",
39+
}
3840

3941

4042
@contextmanager

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def _mpl_to_gtk_cursor(mpl_cursor):
9595
cursors.POINTER: "default",
9696
cursors.SELECT_REGION: "crosshair",
9797
cursors.WAIT: "wait",
98+
cursors.RESIZE_HORIZONTAL: "ew-resize",
99+
cursors.RESIZE_VERTICAL: "ns-resize",
98100
}[mpl_cursor]
99101
return Gdk.Cursor.new_from_name(Gdk.Display.get_default(), name)
100102

lib/matplotlib/backends/backend_qt5.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@
7979
cursors.POINTER: QtCore.Qt.ArrowCursor,
8080
cursors.SELECT_REGION: QtCore.Qt.CrossCursor,
8181
cursors.WAIT: QtCore.Qt.WaitCursor,
82-
}
82+
cursors.RESIZE_HORIZONTAL: QtCore.Qt.SizeHorCursor,
83+
cursors.RESIZE_VERTICAL: QtCore.Qt.SizeVerCursor,
84+
}
8385

8486

8587
# make place holder

lib/matplotlib/backends/backend_webagg_core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ def set_cursor(self, cursor):
380380
backend_tools.Cursors.SELECT_REGION: 'crosshair',
381381
backend_tools.Cursors.MOVE: 'move',
382382
backend_tools.Cursors.WAIT: 'wait',
383+
backend_tools.Cursors.RESIZE_HORIZONTAL: 'ew-resize',
384+
backend_tools.Cursors.RESIZE_VERTICAL: 'ns-resize',
383385
}[cursor]
384386
self.canvas.send_event("cursor", cursor=cursor)
385387
self.cursor = cursor

lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,8 @@ def _set_frame_icon(frame):
10491049
cursors.POINTER: wx.CURSOR_ARROW,
10501050
cursors.SELECT_REGION: wx.CURSOR_CROSS,
10511051
cursors.WAIT: wx.CURSOR_WAIT,
1052+
cursors.RESIZE_HORIZONTAL: wx.CURSOR_SIZEWE,
1053+
cursors.RESIZE_VERTICAL: wx.CURSOR_SIZENS,
10521054
}
10531055

10541056

src/_macosx.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,8 @@ -(void)save_figure:(id)sender
13801380
case 4: [[NSCursor openHandCursor] set]; break;
13811381
/* OSX handles busy state itself so no need to set a cursor here */
13821382
case 5: break;
1383+
case 6: [[NSCursor resizeLeftRightCursor] set]; break;
1384+
case 7: [[NSCursor resizeUpDownCursor] set]; break;
13831385
default: return NULL;
13841386
}
13851387
Py_RETURN_NONE;

0 commit comments

Comments
 (0)