8000 MNT: Move set_cursor to the FigureCanvas by greglucas · Pull Request #22953 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MNT: Move set_cursor to the FigureCanvas #22953

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ def __init__(self, figure):
self._draw_pending = False
self._is_drawing = False

def set_cursor(self, cursor):
# docstring inherited
_macosx.set_cursor(cursor)

def draw(self):
"""Render the figure and update the macosx canvas."""
# The renderer draw is done here; delaying causes problems with code
Expand Down
50 changes: 25 additions & 25 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,25 @@ static CGFloat _get_device_scale(CGContextRef cr)
Py_RETURN_NONE;
}

static PyObject*
FigureCanvas_set_cursor(PyObject* unused, PyObject* args)
{
int i;
if (!PyArg_ParseTuple(args, "i", &i)) { return NULL; }
switch (i) {
case 1: [[NSCursor arrowCursor] set]; break;
case 2: [[NSCursor pointingHandCursor] set]; break;
case 3: [[NSCursor crosshairCursor] set]; break;
case 4: [[NSCursor openHandCursor] set]; break;
/* OSX handles busy state itself so no need to set a cursor here */
case 5: break;
case 6: [[NSCursor resizeLeftRightCursor] set]; break;
case 7: [[NSCursor resizeUpDownCursor] set]; break;
default: return NULL;
}
Py_RETURN_NONE;
}

static PyObject*
FigureCanvas_set_rubberband(FigureCanvas* self, PyObject *args)
{
Expand Down Expand Up @@ -489,14 +508,18 @@ static CGFloat _get_device_scale(CGContextRef cr)
(PyCFunction)FigureCanvas_flush_events,
METH_NOARGS,
NULL}, // docstring inherited
{"set_cursor",
(PyCFunction)FigureCanvas_set_cursor,
METH_VARARGS,
"Set the active cursor."},
{"set_rubberband",
(PyCFunction)FigureCanvas_set_rubberband,
METH_VARARGS,
"Specifies a new rubberband rectangle and invalidates it."},
"Specify a new rubberband rectangle and invalidate it."},
{"remove_rubberband",
(PyCFunction)FigureCanvas_remove_rubberband,
METH_NOARGS,
"Removes the current rubberband rectangle."},
"Remove the current rubberband rectangle."},
{"start_event_loop",
(PyCFunction)FigureCanvas_start_event_loop,
METH_KEYWORDS | METH_VARARGS,
Expand Down Expand Up @@ -1020,25 +1043,6 @@ -(void)save_figure:(id)sender { gil_call_method(toolbar, "save_figure"); }
Py_RETURN_NONE;
}

static PyObject*
set_cursor(PyObject* unused, PyObject* args)
{
int i;
if (!PyArg_ParseTuple(args, "i", &i)) { return NULL; }
switch (i) {
case 1: [[NSCursor arrowCursor] set]; break;
case 2: [[NSCursor pointingHandCursor] set]; break;
case 3: [[NSCursor crosshairCursor] set]; break;
case 4: [[NSCursor openHandCursor] set]; break;
/* OSX handles busy state itself so no need to set a cursor here */
case 5: break;
case 6: [[NSCursor resizeLeftRightCursor] set]; break;
case 7: [[NSCursor resizeUpDownCursor] set]; break;
default: return NULL;
}
Py_RETURN_NONE;
}

@implementation WindowServerConnectionManager
static WindowServerConnectionManager *sharedWindowServerConnectionManager = nil;

Expand Down Expand Up @@ -1916,10 +1920,6 @@ static void context_cleanup(const void* info)
(PyCFunction)choose_save_file,
METH_VARARGS,
"Query the user for a location where to save a file."},
{"set_cursor",
(PyCFunction)set_cursor,
METH_VARARGS,
"Set the active cursor."},
{} /* Sentinel */
},
};
Expand Down
0