diff -r 0258107a9e72 -r 13502d0dda65 brewpanel/sdlgui.c --- a/brewpanel/sdlgui.c Sat Nov 14 17:00:37 2015 +0100 +++ b/brewpanel/sdlgui.c Sat Nov 14 23:40:51 2015 +0100 @@ -554,24 +554,6 @@ /* - * Search a button with a special flag (e.g. SG_DEFAULT or SG_CANCEL). - */ -static int SDLGui_SearchFlaggedButton(const SGOBJ *dlg, int flag) -{ - int i = 0; - - while (dlg[i].type != -1) { - if (dlg[i].flags & flag) - return i; - i++; - } - - return 0; -} - - - -/* * Show dialog. */ int SDLGui_DoDialogInit(SGOBJ *dlg) @@ -617,26 +599,15 @@ */ int SDLGui_DoDialogLoop(SGOBJ *dlg) { - int obj = 0, oldbutton = 0, retbutton = 0, b, i, j; + int obj = 0, retbutton = 0; SDL_Event sdlEvent; - /* - * Is the left mouse button still pressed? Yes -> Handle TOUCHEXIT objects here - */ - SDL_PumpEvents(); - b = SDL_GetMouseState(&i, &j); - obj = SDLGui_FindObj(dlg, i, j); - if (obj > 0 && (dlg[obj].flags & SG_TOUCHEXIT) ) { - oldbutton = obj; - if (b & SDL_BUTTON(1)) { - dlg[obj].state |= SG_SELECTED; - retbutton = obj; - } - } - /* The main loop */ while (retbutton == 0 && !my_shutdown) { + /* + * Poll network for data + */ socket_recv(); if (SDL_PollEvent(&sdlEvent) == 1) { /* Wait for events */ @@ -657,11 +628,7 @@ dlg[obj].state |= SG_SELECTED; SDLGui_DrawButton(dlg, obj); SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4); - oldbutton=obj; - } - if ( dlg[obj].flags & SG_TOUCHEXIT ) { - dlg[obj].state |= SG_SELECTED; - retbutton = obj; + retbutton = obj + 1000; } } break; @@ -674,33 +641,19 @@ /* It was the left button: Find the object under the mouse cursor */ obj = SDLGui_FindObj(dlg, sdlEvent.button.x, sdlEvent.button.y); if (obj > 0) { - switch (dlg[obj].type) { - case SGBUTTON: - if (oldbutton==obj) - retbutton=obj; - break; + if (dlg[obj].type == SGBUTTON) { + dlg[obj].state &= ~SG_SELECTED; + SDLGui_DrawButton(dlg, obj); + SDL_UpdateRect(pSdlGuiScrn, dlg[0].x + dlg[obj].x - 2, dlg[0].y + dlg[obj].y - 2, dlg[obj].w + 4, dlg[obj].h + 4); + retbutton = obj; } } - if (oldbutton > 0) { - dlg[oldbutton].state &= ~SG_SELECTED; - SDLGui_DrawButton(dlg, oldbutton); - SDL_UpdateRect(pSdlGuiScrn, dlg[0].x+dlg[oldbutton].x-2, dlg[0].y+dlg[oldbutton].y-2, dlg[oldbutton].w+4, dlg[oldbutton].h+4); - oldbutton = 0; - } - if (obj >= 0 && (dlg[obj].flags & SG_EXIT)) { - retbutton = obj; - } break; case SDL_MOUSEMOTION: break; case SDL_KEYDOWN: /* Key pressed */ - if (sdlEvent.key.keysym.sym == SDLK_RETURN || sdlEvent.key.keysym.sym == SDLK_KP_ENTER) { - retbutton = SDLGui_SearchFlaggedButton(dlg, SG_DEFAULT); - } else if (sdlEvent.key.keysym.sym == SDLK_ESCAPE) { - retbutton = SDLGui_SearchFlaggedButton(dlg, SG_CANCEL); - } break; } } else {