diff options
Diffstat (limited to 'src/ui/window.c')
-rw-r--r-- | src/ui/window.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index e47b579f..78ea182c 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -189,8 +189,11 @@ static void windowSizeChanged_Window_(iWindow *d) { | |||
189 | iRoot *root = d->roots[i]; | 189 | iRoot *root = d->roots[i]; |
190 | if (root) { | 190 | if (root) { |
191 | root->widget->rect.pos = init_I2(rootSize.x * i, 0); | 191 | root->widget->rect.pos = init_I2(rootSize.x * i, 0); |
192 | root->widget->rect.size = rootSize; /* Reposition roots. */ | 192 | root->widget->rect.size = addX_I2(rootSize, -gap_UI / 4); |
193 | root->widget->minSize = rootSize; | 193 | if (i == 1) { |
194 | root->widget->rect.pos.x += gap_UI / 8; | ||
195 | } | ||
196 | root->widget->minSize = root->widget->rect.size; | ||
194 | updatePadding_Root(root); | 197 | updatePadding_Root(root); |
195 | arrange_Widget(root->widget); | 198 | arrange_Widget(root->widget); |
196 | } | 199 | } |
@@ -220,7 +223,7 @@ static void updateSize_Window_(iWindow *d, iBool notifyAlways) { | |||
220 | void drawWhileResizing_Window(iWindow *d, int w, int h) { | 223 | void drawWhileResizing_Window(iWindow *d, int w, int h) { |
221 | /* This is called while a window resize is in progress, so we can be pretty confident | 224 | /* This is called while a window resize is in progress, so we can be pretty confident |
222 | the size has actually changed. */ | 225 | the size has actually changed. */ |
223 | d->size = init_I2(w, h); | 226 | d->size = coord_Window(d, w, h); |
224 | windowSizeChanged_Window_(d); | 227 | windowSizeChanged_Window_(d); |
225 | draw_Window(d); | 228 | draw_Window(d); |
226 | } | 229 | } |
@@ -274,7 +277,8 @@ static float displayScale_Window_(const iWindow *d) { | |||
274 | } | 277 | } |
275 | 278 | ||
276 | static void drawBlank_Window_(iWindow *d) { | 279 | static void drawBlank_Window_(iWindow *d) { |
277 | const iColor bg = get_Color(uiBackground_ColorId); | 280 | // const iColor bg = get_Color(uiBackground_ColorId); |
281 | const iColor bg = { 128, 128, 128, 255 }; /* TODO: Have no root yet. */ | ||
278 | SDL_SetRenderDrawColor(d->render, bg.r, bg.g, bg.b, 255); | 282 | SDL_SetRenderDrawColor(d->render, bg.r, bg.g, bg.b, 255); |
279 | SDL_RenderClear(d->render); | 283 | SDL_RenderClear(d->render); |
280 | SDL_RenderPresent(d->render); | 284 | SDL_RenderPresent(d->render); |
@@ -373,6 +377,9 @@ void init_Window(iWindow *d, iRect rect) { | |||
373 | d->win = NULL; | 377 | d->win = NULL; |
374 | d->size = zero_I2(); /* will be updated below */ | 378 | d->size = zero_I2(); /* will be updated below */ |
375 | iZap(d->roots); | 379 | iZap(d->roots); |
380 | d->hover = NULL; | ||
381 | d->mouseGrab = NULL; | ||
382 | d->focus = NULL; | ||
376 | iZap(d->cursors); | 383 | iZap(d->cursors); |
377 | d->place.initialPos = rect.pos; | 384 | d->place.initialPos = rect.pos; |
378 | d->place.normalRect = rect; | 385 | d->place.normalRect = rect; |
@@ -520,7 +527,6 @@ iRoot *findRoot_Window(const iWindow *d, const iWidget *widget) { | |||
520 | return d->roots[i]; | 527 | return d->roots[i]; |
521 | } | 528 | } |
522 | } | 529 | } |
523 | iAssert(iFalse); /* it must be under some Root */ | ||
524 | return NULL; | 530 | return NULL; |
525 | } | 531 | } |
526 | 532 | ||
@@ -811,10 +817,7 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
811 | event.button.x = pos.x; | 817 | event.button.x = pos.x; |
812 | event.button.y = pos.y; | 818 | event.button.y = pos.y; |
813 | } | 819 | } |
814 | const iWidget *oldHovers[2] = { | 820 | const iWidget *oldHover = d->hover; |
815 | d->roots[0]->hover, | ||
816 | d->roots[1]->hover, | ||
817 | }; | ||
818 | iBool wasUsed = iFalse; | 821 | iBool wasUsed = iFalse; |
819 | /* Dispatch first to the mouse-grabbed widget. */ | 822 | /* Dispatch first to the mouse-grabbed widget. */ |
820 | // iWidget *widget = d->root.widget; | 823 | // iWidget *widget = d->root.widget; |
@@ -866,7 +869,7 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
866 | } | 869 | } |
867 | } | 870 | } |
868 | } | 871 | } |
869 | if (oldHovers[0] != d->roots[0]->hover || oldHovers[1] != d->roots[1]->hover) { | 872 | if (oldHover != d->hover) { |
870 | postRefresh_App(); | 873 | postRefresh_App(); |
871 | } | 874 | } |
872 | if (event.type == SDL_MOUSEMOTION) { | 875 | if (event.type == SDL_MOUSEMOTION) { |
@@ -879,9 +882,15 @@ iBool processEvent_Window(iWindow *d, const SDL_Event *ev) { | |||
879 | } | 882 | } |
880 | 883 | ||
881 | iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { | 884 | iBool dispatchEvent_Window(iWindow *d, const SDL_Event *ev) { |
882 | /* TODO: Dispatch to input-focused root first. */ | 885 | if (ev->type == SDL_MOUSEMOTION) { |
886 | /* Hover widget may change. */ | ||
887 | setHover_Widget(NULL); | ||
888 | } | ||
883 | iForIndices(i, d->roots) { | 889 | iForIndices(i, d->roots) { |
884 | if (d->roots[i]) { | 890 | if (d->roots[i]) { |
891 | if (isCommand_SDLEvent(ev) && ev->user.data2 && ev->user.data2 != d->roots[i]) { | ||
892 | continue; /* Not meant for this root. */ | ||
893 | } | ||
885 | setCurrent_Root(d->roots[i]); | 894 | setCurrent_Root(d->roots[i]); |
886 | const iBool wasUsed = dispatchEvent_Widget(d->roots[i]->widget, ev); | 895 | const iBool wasUsed = dispatchEvent_Widget(d->roots[i]->widget, ev); |
887 | if (wasUsed) { | 896 | if (wasUsed) { |