diff -r 80967361f257 -r 21e542c15832 brewpanel/sdlgui.c --- a/brewpanel/sdlgui.c Thu Mar 14 19:37:53 2024 +0100 +++ b/brewpanel/sdlgui.c Fri Mar 15 20:57:49 2024 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2015-2020 + * Copyright (C) 2015-2024 * * Michiel Broek * @@ -27,7 +27,7 @@ #include "sdlgui.h" #include "sockio.h" -#ifdef HAVE_SDL_SDL_H +#ifdef HAVE_SDL2_SDL_H #include "lcdfont10x16.h" @@ -44,6 +44,7 @@ extern int my_shutdown; extern int debug; +extern SDL_Window *S_window; /*-----------------------------------------------------------------------*/ /* @@ -104,10 +105,10 @@ } /* Set color palette of the LCD font graphics: */ - SDL_SetColors(pFontGfx, blackWhiteColors, 0, 2); + SDL_SetPaletteColors(pFontGfx->format->palette, blackWhiteColors, 0, 2); /* Set font color 0 as transparent: */ - SDL_SetColorKey(pFontGfx, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0); + SDL_SetColorKey(pFontGfx, SDL_RLEACCEL, 0); if (TTF_Init() == -1) { syslog(LOG_NOTICE, "Could not init SDL_ttf"); @@ -242,7 +243,7 @@ dr.h = 2; SDL_FillRect(pSdlGuiScrn, &dr, color); - SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); +// SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); } } @@ -287,8 +288,8 @@ i++; } - SDL_SetColors(CGchar, blackWhiteColors, 0, 2); - SDL_SetColorKey(CGchar, (SDL_SRCCOLORKEY|SDL_RLEACCEL), 0); +// SDL_SetColors(CGchar, blackWhiteColors, 0, 2); + SDL_SetColorKey(CGchar, SDL_RLEACCEL, 0); bg = LCDbg0; sr.x = sr.y = 0; @@ -299,7 +300,8 @@ SDL_FillRect(pSdlGuiScrn, &dr, bg); SDL_BlitSurface(CGchar, &sr, pSdlGuiScrn, &dr); - SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); + //SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); + SDL_UpdateWindowSurface(S_window); SDL_FreeSurface(CGchar); } @@ -330,7 +332,8 @@ SDL_FillRect(pSdlGuiScrn, &dr, bg); SDL_BlitSurface(pFontGfx, &sr, pSdlGuiScrn, &dr); - SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); +// SDL_UpdateRect(pSdlGuiScrn, x, y, fontwidth, fontheight); + SDL_UpdateWindowSurface(S_window); } @@ -695,7 +698,8 @@ SDLGUI_DrawLEDYellow(dlg, i); break; } - SDL_UpdateRect(pSdlGuiScrn, dlg[i].x - dlg[i].w, dlg[i].y - dlg[i].w, dlg[i].w * 2, dlg[i].w * 2); + SDL_UpdateWindowSurface(S_window); + //SDL_UpdateRect(pSdlGuiScrn, dlg[i].x - dlg[i].w, dlg[i].y - dlg[i].w, dlg[i].w * 2, dlg[i].w * 2); } } } @@ -741,7 +745,8 @@ } } - SDL_UpdateRect(pSdlGuiScrn, 0,0,0,0); + SDL_UpdateWindowSurface(S_window); + // SDL_UpdateRect(pSdlGuiScrn, 0,0,0,0); } @@ -798,7 +803,7 @@ pBgSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, dlgrect.w, dlgrect.h, pSdlGuiScrn->format->BitsPerPixel, pSdlGuiScrn->format->Rmask, pSdlGuiScrn->format->Gmask, pSdlGuiScrn->format->Bmask, pSdlGuiScrn->format->Amask); if (pSdlGuiScrn->format->palette != NULL) { - SDL_SetColors(pBgSurface, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1); + SDL_SetPaletteColors(pBgSurface->format->palette, pSdlGuiScrn->format->palette->colors, 0, pSdlGuiScrn->format->palette->ncolors-1); } if (pBgSurface != NULL) { @@ -847,7 +852,8 @@ 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); + SDL_UpdateWindowSurface(S_window); + //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 + 1000; } } @@ -864,7 +870,8 @@ 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); + SDL_UpdateWindowSurface(S_window); + //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; } }