diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 29af61cf..88a59835 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1899,6 +1899,9 @@ typedef void (* GLFWcharfun)(GLFWwindow* window, unsigned int codepoint); */ 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. * * 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[]); +// 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. * * 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); +// TODO doc +GLFWAPI GLFWdragfun glfwSetDragCallback(GLFWwindow* window, GLFWdragfun callback); + /*! @brief Sets the path drop callback. * * 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); +// TODO doc +GLFWAPI GLFWdropfunex glfwSetDropCallbackEx(GLFWwindow* window, GLFWdropfunex callback); + /*! @brief Returns whether the specified joystick is present. * * This function returns whether the specified joystick is present. diff --git a/src/input.c b/src/input.c index c2a7a86d..247632af 100644 --- a/src/input.c +++ b/src/input.c @@ -401,6 +401,14 @@ void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool 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 // 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); } +// 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 // void _glfwInputJoystick(_GLFWjoystick* js, int event) @@ -1011,6 +1027,16 @@ GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow* handle, 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) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -1021,6 +1047,16 @@ GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow* handle, GLFWdropfun 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) { _GLFWjoystick* js; diff --git a/src/internal.h b/src/internal.h index a23c97c0..1bc9fb72 100644 --- a/src/internal.h +++ b/src/internal.h @@ -582,7 +582,9 @@ struct _GLFWwindow GLFWkeyfun key; GLFWcharfun character; GLFWcharmodsfun charmods; + GLFWdragfun drag; GLFWdropfun drop; + GLFWdropfunex dropex; } callbacks; // 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 _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); 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 _glfwInputDropEx(_GLFWwindow* window, int format, int data_count, void *data, int *action); void _glfwInputJoystick(_GLFWjoystick* js, int event); void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value); void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);