diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-20 21:48:51 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-10-20 21:48:51 +0300 |
commit | 8a2f5a0cab40986d7af88fc9eae7b3931f30fcc3 (patch) | |
tree | f0a32c0ef839dc34cfddae08b4eb4b930fdb7ecd /src/ui/window.c | |
parent | 2052acf054291c2915ace9da9cc1a395c3abf832 (diff) |
Added quote indicator preference
Also, added a command that gets posted when the mouse exits or enters the window area. This lets the hover outline to be updated accordingly.
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index 40215506..c5194ea0 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -524,6 +524,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
524 | d->lastRect = rect; | 524 | d->lastRect = rect; |
525 | d->pendingCursor = NULL; | 525 | d->pendingCursor = NULL; |
526 | d->isDrawFrozen = iTrue; | 526 | d->isDrawFrozen = iTrue; |
527 | d->isMouseInside = iTrue; | ||
527 | uint32_t flags = 0; | 528 | uint32_t flags = 0; |
528 | #if defined (iPlatformApple) | 529 | #if defined (iPlatformApple) |
529 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl"); | 530 | SDL_SetHint(SDL_HINT_RENDER_DRIVER, shouldDefaultToMetalRenderer_MacOS() ? "metal" : "opengl"); |
@@ -543,7 +544,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
543 | if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { | 544 | if (left_Rect(rect) >= 0 || top_Rect(rect) >= 0) { |
544 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); | 545 | SDL_SetWindowPosition(d->win, left_Rect(rect), top_Rect(rect)); |
545 | } | 546 | } |
546 | const iInt2 minSize = init_I2(425, 250); | 547 | const iInt2 minSize = init_I2(425, 300); |
547 | SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y); | 548 | SDL_SetWindowMinimumSize(d->win, minSize.x, minSize.y); |
548 | SDL_SetWindowTitle(d->win, "Lagrange"); | 549 | SDL_SetWindowTitle(d->win, "Lagrange"); |
549 | /* Some info. */ { | 550 | /* Some info. */ { |
@@ -655,6 +656,12 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
655 | return iTrue; | 656 | return iTrue; |
656 | case SDL_WINDOWEVENT_LEAVE: | 657 | case SDL_WINDOWEVENT_LEAVE: |
657 | unhover_Widget(); | 658 | unhover_Widget(); |
659 | d->isMouseInside = iFalse; | ||
660 | postCommand_App("window.mouse.exited"); | ||
661 | return iTrue; | ||
662 | case SDL_WINDOWEVENT_ENTER: | ||
663 | d->isMouseInside = iTrue; | ||
664 | postCommand_App("window.mouse.entered"); | ||
658 | return iTrue; | 665 | return iTrue; |
659 | default: | 666 | default: |
660 | break; | 667 | break; |
@@ -812,6 +819,9 @@ iInt2 coord_Window(const iWindow *d, int x, int y) { | |||
812 | } | 819 | } |
813 | 820 | ||
814 | iInt2 mouseCoord_Window(const iWindow *d) { | 821 | iInt2 mouseCoord_Window(const iWindow *d) { |
822 | if (!d->isMouseInside) { | ||
823 | return init_I2(-1000000, -1000000); | ||
824 | } | ||
815 | int x, y; | 825 | int x, y; |
816 | SDL_GetMouseState(&x, &y); | 826 | SDL_GetMouseState(&x, &y); |
817 | return coord_Window(d, x, y); | 827 | return coord_Window(d, x, y); |