MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / GUI_Widget_TextButton2_Draw

Function GUI_Widget_TextButton2_Draw

src/gui/widget_draw.c:296–355  ·  view source on GitHub ↗

* Draw a text button widget to the display, relative to 0,0. * * @param w The widget (which is a button) to draw. */

Source from the content-addressed store, hash-verified

294 * @param w The widget (which is a button) to draw.
295 */
296void GUI_Widget_TextButton2_Draw(Widget *w)
297{
298 Screen oldScreenID;
299 uint16 stringID;
300 uint16 positionX, positionY;
301 uint16 width, height;
302 uint8 colour;
303 bool buttonSelected;
304 bool buttonDown;
305
306 if (w == NULL) return;
307
308 oldScreenID = SCREEN_ACTIVE;
309 if (GFX_Screen_IsActive(SCREEN_0)) {
310 oldScreenID = GFX_Screen_SetActive(SCREEN_1);
311 }
312
313 stringID = w->stringID;
314
315 buttonSelected = w->state.selected;
316 buttonDown = w->state.hover2;
317
318 positionX = w->offsetX;
319 positionY = w->offsetY;
320 width = w->width;
321 height = w->height;
322
323 GUI_DrawWiredRectangle(positionX - 1, positionY - 1, positionX + width, positionY + height, 12);
324 GUI_DrawBorder(positionX, positionY, width, height, buttonDown ? 0 : 1, true);
325
326 colour = 0xF;
327 if (buttonSelected) {
328 colour = 0x6;
329 } else if (buttonDown) {
330 colour = 0xE;
331 }
332
333 if (!buttonDown && stringID == STR_REPAIR) {
334 colour = 0xEF;
335 }
336
337 GUI_DrawText_Wrapper(
338 String_Get_ByIndex(stringID),
339 positionX + width / 2,
340 positionY + 1,
341 colour,
342 0,
343 0x121
344 );
345
346 w->shortcut = GUI_Widget_GetShortcut(*String_Get_ByIndex(stringID));
347
348 if (oldScreenID != SCREEN_0) return;
349
350 GUI_Mouse_Hide_InRegion(positionX - 1, positionY - 1, positionX + width + 1, positionY + height + 1);
351 GFX_Screen_Copy2(positionX - 1, positionY - 1, positionX - 1, positionY - 1, width + 2, height + 2, SCREEN_1, SCREEN_0, false);
352 GUI_Mouse_Show_InRegion();
353

Callers

nothing calls this directly

Calls 10

GFX_Screen_IsActiveFunction · 0.85
GFX_Screen_SetActiveFunction · 0.85
GUI_DrawWiredRectangleFunction · 0.85
GUI_DrawBorderFunction · 0.85
GUI_DrawText_WrapperFunction · 0.85
String_Get_ByIndexFunction · 0.85
GUI_Widget_GetShortcutFunction · 0.85
GUI_Mouse_Hide_InRegionFunction · 0.85
GFX_Screen_Copy2Function · 0.85
GUI_Mouse_Show_InRegionFunction · 0.85

Tested by

no test coverage detected