static struct GadgetInfo *last_info_gi = NULL;
static int next_free_gadget_id = 1;
static boolean gadget_id_wrapped = FALSE;
+static int gadget_screen_border_right = -1;
+static int gadget_screen_border_bottom = -1;
static void (*PlayGadgetSoundActivating)(void) = NULL;
static void (*PlayGadgetSoundSelecting)(void) = NULL;
PlayGadgetSoundSelecting = selecting_function;
}
+void InitGadgetScreenBorders(int border_right, int border_bottom)
+{
+ gadget_screen_border_right = border_right;
+ gadget_screen_border_bottom = border_bottom;
+}
+
+static int getGadgetScreenBorderRight(void)
+{
+ if (gadget_screen_border_right < gfx.sx ||
+ gadget_screen_border_right > gfx.sx + gfx.sxsize)
+ return gfx.sx + gfx.sxsize;
+
+ return gadget_screen_border_right;
+}
+
+static int getGadgetScreenBorderBottom(void)
+{
+ if (gadget_screen_border_bottom < gfx.sy ||
+ gadget_screen_border_bottom > gfx.sy + gfx.sysize)
+ return gfx.sy + gfx.sysize;
+
+ return gadget_screen_border_bottom;
+}
+
static struct GadgetInfo *getGadgetInfoFromGadgetID(int id)
{
struct GadgetInfo *gi = gadget_list_first_entry;
{
case GD_TYPE_NORMAL_BUTTON:
case GD_TYPE_CHECK_BUTTON:
+ case GD_TYPE_CHECK_BUTTON_2:
case GD_TYPE_RADIO_BUTTON:
BlitBitmapOnBackground(gd->bitmap, drawto,
int border_x = gi->border.xsize;
int border_y = gi->border.ysize;
int gd_height = 2 * border_y + font_height;
+ int x = gi->x;
+ int y = gi->y;
+ int width = gi->width;
+ int height = gi->height;
+ int xsize = gi->textarea.xsize;
+ int ysize = gi->textarea.ysize;
// top left part of gadget border
BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y,
- border_x, border_y, gi->x, gi->y);
+ border_x, border_y, x, y);
// top middle part of gadget border
- for (i=0; i < gi->textarea.xsize; i++)
+ for (i=0; i < xsize; i++)
BlitBitmapOnBackground(gd->bitmap, drawto, gd->x + border_x, gd->y,
font_width, border_y,
- gi->x + border_x + i * font_width, gi->y);
+ x + border_x + i * font_width, y);
// top right part of gadget border
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x + gi->border.width - border_x, gd->y,
border_x, border_y,
- gi->x + gi->width - border_x, gi->y);
+ x + width - border_x, y);
// left and right part of gadget border for each row
- for (i=0; i < gi->textarea.ysize; i++)
+ for (i=0; i < ysize; i++)
{
BlitBitmapOnBackground(gd->bitmap, drawto, gd->x, gd->y + border_y,
border_x, font_height,
- gi->x, gi->y + border_y + i * font_height);
+ x, y + border_y + i * font_height);
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x + gi->border.width - border_x,
gd->y + border_y,
border_x, font_height,
- gi->x + gi->width - border_x,
- gi->y + border_y + i * font_height);
+ x + width - border_x,
+ y + border_y + i * font_height);
}
// bottom left part of gadget border
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x, gd->y + gd_height - border_y,
border_x, border_y,
- gi->x, gi->y + gi->height - border_y);
+ x, y + height - border_y);
// bottom middle part of gadget border
- for (i=0; i < gi->textarea.xsize; i++)
+ for (i=0; i < xsize; i++)
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x + border_x,
gd->y + gd_height - border_y,
font_width, border_y,
- gi->x + border_x + i * font_width,
- gi->y + gi->height - border_y);
+ x + border_x + i * font_width,
+ y + height - border_y);
// bottom right part of gadget border
BlitBitmapOnBackground(gd->bitmap, drawto,
gd->x + gi->border.width - border_x,
gd->y + gd_height - border_y,
border_x, border_y,
- gi->x + gi->width - border_x,
- gi->y + gi->height - border_y);
+ x + width - border_x,
+ y + height - border_y);
ClearRectangleOnBackground(drawto,
- gi->x + border_x,
- gi->y + border_y,
- gi->width - 2 * border_x,
- gi->height - 2 * border_y);
+ x + border_x,
+ y + border_y,
+ width - 2 * border_x,
+ height - 2 * border_y);
// gadget text value
- DrawTextArea(gi->x + border_x, gi->y + border_y, gi->textarea.value,
- font_nr, gi->textarea.xsize, -1, gi->textarea.ysize, 0,
+ DrawTextArea(x + border_x, y + border_y, gi->textarea.value,
+ font_nr, xsize, -1, ysize, 0,
BLIT_ON_BACKGROUND, FALSE, FALSE, FALSE);
cursor_letter = gi->textarea.value[gi->textarea.cursor_position];
// draw cursor, if active
if (pressed)
DrawTextExt(drawto,
- gi->x + border_x + gi->textarea.cursor_x * font_width,
- gi->y + border_y + gi->textarea.cursor_y * font_height,
+ x + border_x + gi->textarea.cursor_x * font_width,
+ y + border_y + gi->textarea.cursor_y * font_height,
cursor_string,
font_nr, BLIT_INVERSE);
}
{
case GD_TYPE_NORMAL_BUTTON:
case GD_TYPE_CHECK_BUTTON:
+ case GD_TYPE_CHECK_BUTTON_2:
case GD_TYPE_RADIO_BUTTON:
SDL_SetTextureAlphaMod(gd->bitmap->texture_masked, alpha);
SDL_SetTextureBlendMode(gd->bitmap->texture_masked, SDL_BLENDMODE_BLEND);
int border_xsize = gi->border.xsize;
int border_ysize = gi->border.ysize;
int button_size = gi->border.xsize_selectbutton;
- int bottom_screen_border = gfx.sy + gfx.sysize - font_height;
+ int bottom_screen_border = getGadgetScreenBorderBottom();
Bitmap *src_bitmap;
int src_x, src_y;
boolean HandleGadgets(int mx, int my, int button)
{
- static unsigned int pressed_delay = 0;
- static unsigned int pressed_delay_value = GADGET_FRAME_DELAY;
+ static DelayCounter pressed_delay = { GADGET_FRAME_DELAY };
static int last_button = 0;
static int last_mx = 0, last_my = 0;
static int pressed_mx = 0, pressed_my = 0;
(button != 0 && last_gi != NULL && new_gi == last_gi);
gadget_pressed_delay_reached =
- DelayReached(&pressed_delay, pressed_delay_value);
+ DelayReached(&pressed_delay);
gadget_released = (release_event && last_gi != NULL);
gadget_released_inside = (gadget_released && new_gi == last_gi);
ResetDelayCounter(&pressed_delay);
// start gadget delay with longer delay after first click on gadget
- pressed_delay_value = GADGET_FRAME_DELAY_FIRST;
+ pressed_delay.value = GADGET_FRAME_DELAY_FIRST;
}
else // gadget hold pressed for some time
{
// after first repeated gadget click, continue with shorter delay value
- pressed_delay_value = GADGET_FRAME_DELAY;
+ pressed_delay.value = GADGET_FRAME_DELAY;
}
if (gi->type & GD_TYPE_SCROLLBAR && !gadget_dragging)
boolean deactivate_gadget = TRUE;
boolean gadget_changed = TRUE;
- if (gi->type & GD_TYPE_SELECTBOX)
+ if (gi->type == GD_TYPE_CHECK_BUTTON_2)
+ {
+ gi->checked = !gi->checked;
+ }
+ else if (gi->type & GD_TYPE_SELECTBOX)
{
if (keep_selectbox_open ||
mouse_released_where_pressed ||