Implement UI cursor (WIP)
This commit is contained in:
parent
aba3d387e6
commit
725aebf3b1
@ -60,6 +60,9 @@ static void defaultKey(GLFWwindow *window, int key, int scancode, int action, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *data) {
|
static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *data) {
|
||||||
|
switch(Input::getCursorMode()) {
|
||||||
|
case GLFWCursorMode::CAPTURE:
|
||||||
|
{
|
||||||
static bool firstMouse = true;
|
static bool firstMouse = true;
|
||||||
static double lastX = 0, lastY = 0;
|
static double lastX = 0, lastY = 0;
|
||||||
if(firstMouse) {
|
if(firstMouse) {
|
||||||
@ -79,6 +82,16 @@ static void defaultMouseCallback(GLFWwindow *window, double x, double y, void *d
|
|||||||
kekData.activeCamera->rotateYaw(xoff);
|
kekData.activeCamera->rotateYaw(xoff);
|
||||||
kekData.activeCamera->rotatePitch(yoff);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
keyForward = Input::createKeyBinding("Forward", GLFW_KEY_W);
|
keyForward = Input::createKeyBinding("Forward", GLFW_KEY_W);
|
||||||
|
@ -223,7 +223,7 @@ void ButtonElement::setOnClickCallback(Callable onClick) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ButtonElement::hover(UIPoint pos, UIPoint screenPos) {
|
void ButtonElement::hover(UIPoint pos, UIPoint screenPos) {
|
||||||
|
RectangleElement::setColor(Colors::YELLOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonElement::hoverEnter() {
|
void ButtonElement::hoverEnter() {
|
||||||
|
Loading…
Reference in New Issue
Block a user