Skip to content

Commit

Permalink
SDL module: added unset gadget code
Browse files Browse the repository at this point in the history
  • Loading branch information
koder77 committed Jan 19, 2024
1 parent f0d9c0f commit 058e749
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include-lib/sdl-lib.l1h
Expand Up @@ -69,6 +69,7 @@
(set string s free_all_gadgetsstr@sdl "free_all_gadgets")
(set string s set_window_titlestr@sdl "sdl_set_window_title")
(set string s set_gadget_menustr@sdl "set_gadget_menu")
(set string s unset_gadgetstr@sdl "unset_gadget")
(set int64 1 open@sdl 0)
(set int64 1 quit@sdl 1)
(set int64 1 update@sdl 2)
Expand Down Expand Up @@ -130,6 +131,7 @@
(set int64 1 free_all_gadgets@sdl 59)
(set int64 1 set_window_title@sdl 60)
(set int64 1 set_gadget_menu@sdl 61)
(set int64 1 unset_gadget@sdl 62)
// call arguments
(set int64 1 width@sdl 0)
(set int64 1 height@sdl 0)
Expand Down Expand Up @@ -206,6 +208,7 @@
(2 mod@sdl free_all_gadgets@sdl free_all_gadgetsstr@sdladdr intr0)
(2 mod@sdl set_window_title@sdl set_window_titlestr@sdladdr intr0)
(2 mod@sdl set_gadget_menu@sdl set_gadget_menustr@sdladdr intr0)
(2 mod@sdl unset_gadget@sdl unset_gadgetstr@sdladdr intr0)
(width@sdl stpushi)
(height@sdl stpushi)
(bit@sdl stpushi)
Expand Down Expand Up @@ -417,3 +420,6 @@
(sdl_set_window_title func)
(3 mod@sdl set_window_title@sdl 0 intr0)
(funcend)
(sdl_unset_gadget func)
(3 mod@sdl unset_gadget@sdl 0 intr0)
(funcend)
37 changes: 37 additions & 0 deletions vm/modules/sdl-2.0/gui.c
Expand Up @@ -7520,3 +7520,40 @@ U1 *free_all_gadgets (U1 *sp, U1 *sp_top, U1 *sp_bottom, U1 *data)

return (sp);
}

U1 *unset_gadget (U1 *sp, U1 *sp_top, U1 *sp_bottom, U1 *data)
{
// this just unsets a gadget from the gadgets list.
// You have to blank it out by overpainting it by the window background color!

S8 gadget_index ALIGN;

sp = stpopi ((U1 *) &gadget_index, sp, sp_top);
if (sp == NULL)
{
printf ("unset_gadet: error missing gadget index!\n");
return (NULL);
}

if (! screen[screennum].gadget)
{
printf ("unset_gadget: error gadget list not allocated!\n");
return (NULL);
}

if (gadget_index >= screen[screennum].gadgets)
{
printf ("unset_gadget error gadget index out of range!\n");
return (NULL);
}

if (! screen[screennum].font_ttf.font)
{
printf ("unset_gadget: error no ttf font loaded!\n");
return (NULL);
}

free_gadget (screennum, gadget_index);

return (sp);
}

0 comments on commit 058e749

Please sign in to comment.