diff --git a/src/custom/RemoteNanoVG.cpp b/src/custom/RemoteNanoVG.cpp index 7091097..a299cf0 100644 --- a/src/custom/RemoteNanoVG.cpp +++ b/src/custom/RemoteNanoVG.cpp @@ -54,6 +54,7 @@ typedef struct GLFWwindow GLFWwindow; GLFWAPI const char* glfwGetClipboardString(GLFWwindow*) { return nullptr; } GLFWAPI void glfwSetClipboardString(GLFWwindow*, const char*) {} +GLFWAPI GLFWcursor* glfwCreateStandardCursor(int) { return nullptr; } GLFWAPI void glfwSetCursor(GLFWwindow*, GLFWcursor*) {} GLFWAPI const char* glfwGetKeyName(int, int) { return nullptr; } GLFWAPI int glfwGetKeyScancode(int) { return 0; } diff --git a/src/custom/glfw.cpp b/src/custom/glfw.cpp index 9e42296..250586e 100644 --- a/src/custom/glfw.cpp +++ b/src/custom/glfw.cpp @@ -20,6 +20,10 @@ #include +typedef struct GLFWcursor { + DGL_NAMESPACE::MouseCursor cursorId; +} GLFWcursor; + GLFWAPI int glfwGetKeyScancode(int) { return 0; } GLFWAPI const char* glfwGetClipboardString(GLFWwindow*) @@ -43,13 +47,53 @@ GLFWAPI void glfwSetClipboardString(GLFWwindow*, const char* const text) context->ui->setClipboard(nullptr, text, std::strlen(text)+1); } +GLFWAPI GLFWcursor* glfwCreateStandardCursor(const int shape) +{ + static GLFWcursor cursors[] = { + { kMouseCursorArrow }, // GLFW_ARROW_CURSOR + { kMouseCursorCaret }, // GLFW_IBEAM_CURSOR + { kMouseCursorCrosshair }, // GLFW_CROSSHAIR_CURSOR + { kMouseCursorHand }, // GLFW_POINTING_HAND_CURSOR + { kMouseCursorNotAllowed }, // GLFW_NOT_ALLOWED_CURSOR + { kMouseCursorLeftRight }, // GLFW_RESIZE_EW_CURSOR + { kMouseCursorUpDown }, // GLFW_RESIZE_NS_CURSOR + { kMouseCursorDiagonal }, // GLFW_RESIZE_NWSE_CURSOR + { kMouseCursorAntiDiagonal }, // GLFW_RESIZE_NESW_CURSOR + // NOTE GLFW_RESIZE_ALL_CURSOR is unsupported in pugl + }; + + switch (shape) + { + case GLFW_ARROW_CURSOR: + return &cursors[kMouseCursorArrow]; + case GLFW_IBEAM_CURSOR: + return &cursors[kMouseCursorCaret]; + case GLFW_CROSSHAIR_CURSOR: + return &cursors[kMouseCursorCrosshair]; + case GLFW_POINTING_HAND_CURSOR: + return &cursors[kMouseCursorHand]; + case GLFW_NOT_ALLOWED_CURSOR: + return &cursors[kMouseCursorNotAllowed]; + case GLFW_RESIZE_EW_CURSOR: + return &cursors[kMouseCursorLeftRight]; + case GLFW_RESIZE_NS_CURSOR: + return &cursors[kMouseCursorUpDown]; + case GLFW_RESIZE_NWSE_CURSOR: + return &cursors[kMouseCursorDiagonal]; + case GLFW_RESIZE_NESW_CURSOR: + return &cursors[kMouseCursorAntiDiagonal]; + default: + return nullptr; + } +} + GLFWAPI void glfwSetCursor(GLFWwindow*, GLFWcursor* const cursor) { CardinalPluginContext* const context = static_cast(APP); DISTRHO_SAFE_ASSERT_RETURN(context != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(context->ui != nullptr,); - context->ui->setCursor(cursor != nullptr ? kMouseCursorDiagonal : kMouseCursorArrow); + context->ui->setCursor(cursor != nullptr ? cursor->cursorId : kMouseCursorArrow); } GLFWAPI double glfwGetTime(void) diff --git a/src/override/Scene.cpp b/src/override/Scene.cpp index 03c4354..b69bc80 100644 --- a/src/override/Scene.cpp +++ b/src/override/Scene.cpp @@ -108,11 +108,11 @@ struct ResizeHandle : widget::OpaqueWidget { } void onEnter(const EnterEvent& e) override { - glfwSetCursor(nullptr, (GLFWcursor*)0x1); + glfwSetCursor(APP->window->win, glfwCreateStandardCursor(GLFW_RESIZE_NWSE_CURSOR)); } void onLeave(const LeaveEvent& e) override { - glfwSetCursor(nullptr, nullptr); + glfwSetCursor(APP->window->win, nullptr); } void onDragStart(const DragStartEvent&) override {