diff --git a/src/kekengine/cpp/defaults.cpp b/src/kekengine/cpp/defaults.cpp index df24649..a7ba046 100644 --- a/src/kekengine/cpp/defaults.cpp +++ b/src/kekengine/cpp/defaults.cpp @@ -60,24 +60,37 @@ static void defaultKey(GLFWwindow *window, int key, int scancode, int action, in } static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *data) { - static bool firstMouse = true; - static double lastX = 0, lastY = 0; - if(firstMouse) { - lastX = x; - lastY = y; - firstMouse = false; + switch(Input::getCursorMode()) { + case GLFWCursorMode::CAPTURE: + { + static bool firstMouse = true; + static double lastX = 0, lastY = 0; + if(firstMouse) { + lastX = x; + lastY = y; + firstMouse = false; + } + + float xoff = lastX - x; + float yoff = lastY - y; + lastX = x; + lastY = y; + + xoff *= 0.1f; + yoff *= 0.1f; + + kekData.activeCamera->rotateYaw(xoff); + kekData.activeCamera->rotatePitch(yoff); + } + case GLFWCursorMode::FREE: + case GLFWCursorMode::HIDDEN: + { + for(UIElement *element : kekData.uiElements) { + UIPoint childPos = element->getPosition(); + if(element->hoverAll(UIPoint((int) x - childPos.x, (int) y - childPos.y), UIPoint((int) x, (int) y))) break; + } + } } - - float xoff = lastX - x; - float yoff = lastY - y; - lastX = x; - lastY = y; - - xoff *= 0.1f; - yoff *= 0.1f; - - kekData.activeCamera->rotateYaw(xoff); - kekData.activeCamera->rotatePitch(yoff); } void init() { diff --git a/src/kekengine/cpp/uielements.cpp b/src/kekengine/cpp/uielements.cpp index 81c9ee8..1337b80 100644 --- a/src/kekengine/cpp/uielements.cpp +++ b/src/kekengine/cpp/uielements.cpp @@ -223,7 +223,7 @@ void ButtonElement::setOnClickCallback(Callable onClick) { } void ButtonElement::hover(UIPoint pos, UIPoint screenPos) { - + RectangleElement::setColor(Colors::YELLOW); } void ButtonElement::hoverEnter() {