Add extended drag & drop callback functions

This commit is contained in:
Florian Albrechtskirchinger 2022-06-10 23:01:12 +02:00
parent a76293fa40
commit 735f31454e
No known key found for this signature in database
GPG Key ID: 19618CE9B2D4BE6D
3 changed files with 52 additions and 0 deletions

View File

@ -1899,6 +1899,9 @@ typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint);
*/ */
typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods); typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int mods);
// TODO doc
typedef void (* GLFWdragfun)(GLFWwindow* window, int event, double xpos, double ypos, int availableFormats, int *format, int availableActions, int *action);
/*! @brief The function pointer type for path drop callbacks. /*! @brief The function pointer type for path drop callbacks.
* *
* This is the function pointer type for path drop callbacks. A path drop * This is the function pointer type for path drop callbacks. A path drop
@ -1923,6 +1926,9 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int
*/ */
typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]); typedef void (* GLFWdropfun)(GLFWwindow* window, int path_count, const char* paths[]);
// TODO doc
typedef void (* GLFWdropfunex)(GLFWwindow* window, int format, int data_count, void *data, int *action);
/*! @brief The function pointer type for monitor configuration callbacks. /*! @brief The function pointer type for monitor configuration callbacks.
* *
* This is the function pointer type for monitor configuration callbacks. * This is the function pointer type for monitor configuration callbacks.
@ -5303,6 +5309,9 @@ GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow* window, GLFWcu
*/ */
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback); GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun callback);
// TODO doc
GLFWAPI GLFWdragfun glfwSetDragCallback(GLFWwindow* window, GLFWdragfun callback);
/*! @brief Sets the path drop callback. /*! @brief Sets the path drop callback.
* *
* This function sets the path drop callback of the specified window, which is * This function sets the path drop callback of the specified window, which is
@ -5340,6 +5349,9 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* window, GLFWscrollfun ca
*/ */
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback); GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* window, GLFWdropfun callback);
// TODO doc
GLFWAPI GLFWdropfunex glfwSetDropCallbackEx(GLFWwindow* window, GLFWdropfunex callback);
/*! @brief Returns whether the specified joystick is present. /*! @brief Returns whether the specified joystick is present.
* *
* This function returns whether the specified joystick is present. * This function returns whether the specified joystick is present.

View File

@ -401,6 +401,14 @@ void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
window->callbacks.cursorEnter((GLFWwindow*) window, entered); window->callbacks.cursorEnter((GLFWwindow*) window, entered);
} }
// Notifies shared code of data being dragged in/over/out of a window
//
void _glfwInputDrag(_GLFWwindow* window, int event, double xpos, double ypos, int availableFormats, int *format, int availableActions, int *action)
{
if (window->callbacks.drag)
window->callbacks.drag((GLFWwindow*) window, event, xpos, ypos, availableFormats, format, availableActions, action);
}
// Notifies shared code of files or directories dropped on a window // Notifies shared code of files or directories dropped on a window
// //
void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths) void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
@ -413,6 +421,14 @@ void _glfwInputDrop(_GLFWwindow* window, int count, const char** paths)
window->callbacks.drop((GLFWwindow*) window, count, paths); window->callbacks.drop((GLFWwindow*) window, count, paths);
} }
// Notifies shared code of data dropped on a window
//
void _glfwInputDropEx(_GLFWwindow* window, int format, int data_count, void *data, int *action)
{
if (window->callbacks.dropex)
window->callbacks.dropex((GLFWwindow*) window, format, data_count, data, action);
}
// Notifies shared code of a joystick connection or disconnection // Notifies shared code of a joystick connection or disconnection
// //
void _glfwInputJoystick(_GLFWjoystick* js, int event) void _glfwInputJoystick(_GLFWjoystick* js, int event)
@ -1011,6 +1027,16 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle,
return cbfun; return cbfun;
} }
GLFWAPI GLFWdragfun glfwSetDragCallback(GLFWwindow* handle, GLFWdragfun cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWdragfun, window->callbacks.drag, cbfun);
return cbfun;
}
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun) GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
{ {
_GLFWwindow* window = (_GLFWwindow*) handle; _GLFWwindow* window = (_GLFWwindow*) handle;
@ -1021,6 +1047,16 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun cbfun)
return cbfun; return cbfun;
} }
GLFWAPI GLFWdropfunex glfwSetDropCallbackEx(GLFWwindow* handle, GLFWdropfunex cbfun)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
_GLFW_SWAP(GLFWdropfunex, window->callbacks.dropex, cbfun);
return cbfun;
}
GLFWAPI int glfwJoystickPresent(int jid) GLFWAPI int glfwJoystickPresent(int jid)
{ {
_GLFWjoystick* js; _GLFWjoystick* js;

View File

@ -582,7 +582,9 @@ struct _GLFWwindow
GLFWkeyfun key; GLFWkeyfun key;
GLFWcharfun character; GLFWcharfun character;
GLFWcharmodsfun charmods; GLFWcharmodsfun charmods;
GLFWdragfun drag;
GLFWdropfun drop; GLFWdropfun drop;
GLFWdropfunex dropex;
} callbacks; } callbacks;
// This is defined in platform.h // This is defined in platform.h
@ -937,7 +939,9 @@ void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
void _glfwInputDrag(_GLFWwindow* window, int event, double xpos, double ypos, int availableFormats, int *format, int availableActions, int *action);
void _glfwInputDrop(_GLFWwindow* window, int count, const char** names); void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
void _glfwInputDropEx(_GLFWwindow* window, int format, int data_count, void *data, int *action);
void _glfwInputJoystick(_GLFWjoystick* js, int event); void _glfwInputJoystick(_GLFWjoystick* js, int event);
void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value); void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value); void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);