Implement UI cursor (WIP)
This commit is contained in:
parent
aba3d387e6
commit
725aebf3b1
@ -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() {
|
||||
|
@ -223,7 +223,7 @@ void ButtonElement::setOnClickCallback(Callable onClick) {
|
||||
}
|
||||
|
||||
void ButtonElement::hover(UIPoint pos, UIPoint screenPos) {
|
||||
|
||||
RectangleElement::setColor(Colors::YELLOW);
|
||||
}
|
||||
|
||||
void ButtonElement::hoverEnter() {
|
||||
|
Loading…
Reference in New Issue
Block a user