// (c) 1995-2014 by Artsoft Entertainment
// Holger Schemel
// info@artsoft.org
-// http://www.artsoft.org/
+// https://www.artsoft.org/
// ----------------------------------------------------------------------------
// gadgets.h
// ============================================================================
#include "system.h"
-#define GADGET_FRAME_DELAY_FIRST 250 /* delay after first click */
-#define GADGET_FRAME_DELAY 100 /* delay for pressed butten */
+#define GADGET_FRAME_DELAY_FIRST 250 // delay after first click
+#define GADGET_FRAME_DELAY 100 // delay for pressed butten
-/* gadget types */
+// gadget types
#define GD_TYPE_NORMAL_BUTTON (1 << 0)
#define GD_TYPE_TEXT_BUTTON (1 << 1)
#define GD_TYPE_CHECK_BUTTON (1 << 2)
#define GD_TYPE_TEXT_INPUT (GD_TYPE_TEXT_INPUT_ALPHANUMERIC | \
GD_TYPE_TEXT_INPUT_NUMERIC)
-/* gadget events */
+// gadget events
#define GD_EVENT_PRESSED (1 << 0)
#define GD_EVENT_RELEASED (1 << 1)
#define GD_EVENT_MOVING (1 << 2)
#define GD_EVENT_INFO_LEAVING (1 << 8)
#define GD_EVENT_PIXEL_PRECISE (1 << 9)
-/* gadget button states */
+// gadget button states
#define GD_BUTTON_UNPRESSED 0
#define GD_BUTTON_PRESSED 1
-/* gadget structure constants */
+// gadget structure constants
#define MAX_GADGET_TEXTSIZE 1024
#define MAX_INFO_TEXTSIZE 1024
-/* gadget creation tags */
+// gadget creation tags
#define GDI_END 0
#define GDI_IMAGE_ID 1
#define GDI_CUSTOM_ID 2
#define GDI_INFO_TEXT 48
#define GDI_ACTIVE 49
#define GDI_DIRECT_DRAW 50
-#define GDI_CALLBACK_ACTION_ALWAYS 51
+#define GDI_OVERLAY_TOUCH_BUTTON 51
+#define GDI_CALLBACK_ACTION_ALWAYS 52
-/* gadget deactivation hack */
+// gadget deactivation hack
#define GDI_ACTIVE_POS(a) ((a) < 0 ? POS_OFFSCREEN : (a))
struct GadgetBorder
{
- int xsize, ysize; /* size of gadget border */
- int xsize_selectbutton; /* for selectbox gadgets */
- int width; /* for selectbox/text input gadgets */
+ int xsize, ysize; // size of gadget border
+ int xsize_selectbutton; // for selectbox gadgets
+ int width; // for selectbox/text input gadgets
};
struct GadgetDesign
{
- Bitmap *bitmap; /* Bitmap with gadget surface */
- int x, y; /* position of rectangle in Bitmap */
+ Bitmap *bitmap; // Bitmap with gadget surface
+ int x, y; // position of rectangle in Bitmap
};
struct GadgetDecoration
{
- struct GadgetDesign design; /* decoration design structure */
- int x, y; /* position of deco on the gadget */
- int width, height; /* width and height of decoration */
- int xshift, yshift; /* deco shifting when gadget pressed */
- boolean masked; /* draw decoration masked over button */
+ struct GadgetDesign design; // decoration design structure
+ int x, y; // position of deco on the gadget
+ int width, height; // width and height of decoration
+ int xshift, yshift; // deco shifting when gadget pressed
+ boolean masked; // draw decoration masked over button
};
struct GadgetEvent
{
- unsigned int type; /* event type */
- int button; /* button number for button events */
- int mx, my; /* raw gadget position at event time */
- int x, y; /* gadget position at event time */
- boolean off_borders; /* mouse pointer outside gadget? */
- int item_x, item_y, item_position; /* new item position */
+ unsigned int type; // event type
+ int button; // button number for button events
+ int mx, my; // raw gadget position at event time
+ int x, y; // gadget position at event time
+ boolean off_borders; // mouse pointer outside gadget?
+ int item_x, item_y, item_position; // new item position
};
struct GadgetDrawingArea
{
- int area_xsize, area_ysize; /* size of drawing area (in items) */
- int item_xsize, item_ysize; /* size of each item in drawing area */
+ int area_xsize, area_ysize; // size of drawing area (in items)
+ int item_xsize, item_ysize; // size of each item in drawing area
};
struct GadgetTextButton
{
- char value[MAX_GADGET_TEXTSIZE + 1]; /* text written on the button */
- int size; /* maximal size of button text */
+ char value[MAX_GADGET_TEXTSIZE + 1]; // text written on the button
+ int size; // maximal size of button text
};
struct GadgetTextInput
{
- char value[MAX_GADGET_TEXTSIZE + 1]; /* text string in input field */
- char last_value[MAX_GADGET_TEXTSIZE + 1];/* last text string in input field */
- int cursor_position; /* actual text cursor position */
- int number_value; /* integer value, if numeric */
- int number_min; /* minimal allowed numeric value */
- int number_max; /* maximal allowed numeric value */
- int size; /* maximal size of input text */
+ char value[MAX_GADGET_TEXTSIZE + 1]; // text string in input field
+ char last_value[MAX_GADGET_TEXTSIZE + 1];// last text string in input field
+ int cursor_position; // actual text cursor position
+ int number_value; // integer value, if numeric
+ int number_min; // minimal allowed numeric value
+ int number_max; // maximal allowed numeric value
+ int size; // maximal size of input text
};
struct GadgetTextArea
{
- char value[MAX_GADGET_TEXTSIZE + 1]; /* text string in input field */
- char last_value[MAX_GADGET_TEXTSIZE + 1];/* last text string in input field */
- int cursor_position; /* actual text cursor position */
- int cursor_x; /* actual x cursor position */
- int cursor_y; /* actual y cursor position */
- int cursor_x_preferred; /* "preferred" x cursor position */
- int size; /* maximal size of input text */
- int xsize, ysize; /* size of text area (in chars) */
+ char value[MAX_GADGET_TEXTSIZE + 1]; // text string in input field
+ char last_value[MAX_GADGET_TEXTSIZE + 1];// last text string in input field
+ int cursor_position; // actual text cursor position
+ int cursor_x; // actual x cursor position
+ int cursor_y; // actual y cursor position
+ int cursor_x_preferred; // "preferred" x cursor position
+ int size; // maximal size of input text
+ int xsize, ysize; // size of text area (in chars)
};
struct GadgetSelectbox
{
- struct ValueTextInfo *options; /* pointer to text/value array */
- int index; /* index of actual text string */
- int size; /* maximal size of text strings */
- char char_unselectable; /* first char of unselectable options */
-
- /* automatically determined values */
- int x, y; /* open selectbox position */
- int width, height; /* open selectbox size */
- int num_values; /* number of text strings */
- Pixel inverse_color; /* color for highlighting */
-
- /* runtime values */
- boolean open; /* opening state of selectbox */
- boolean stay_open; /* open after button release */
- int current_index; /* index of text while selecting */
+ struct ValueTextInfo *options; // pointer to text/value array
+ int index; // index of actual text string
+ int size; // maximal size of text strings
+ char char_unselectable; // first char of unselectable options
+
+ // automatically determined values
+ int x, y; // open selectbox position
+ int width, height; // open selectbox size
+ int num_values; // number of text strings
+ Pixel inverse_color; // color for highlighting
+
+ // runtime values
+ boolean open; // opening state of selectbox
+ boolean stay_open; // open after button release
+ int current_index; // index of text while selecting
};
struct GadgetScrollbar
{
- int items_max; /* number of items to access */
- int items_visible; /* number of visible items */
- int item_position; /* actual item position */
- int size_min; /* minimal scrollbar size */
- int size_max; /* this is either width or height */
- int size_max_cmp; /* needed for minimal scrollbar size */
- int size; /* scrollbar size on screen */
- int position; /* scrollbar position on screen */
- int position_max; /* bottom/right scrollbar position */
- int drag_position; /* drag position on scrollbar */
- int correction; /* scrollbar position correction */
+ int items_max; // number of items to access
+ int items_visible; // number of visible items
+ int item_position; // actual item position
+ int size_min; // minimal scrollbar size
+ int size_max; // this is either width or height
+ int size_max_cmp; // needed for minimal scrollbar size
+ int size; // scrollbar size on screen
+ int position; // scrollbar position on screen
+ int position_max; // bottom/right scrollbar position
+ int drag_position; // drag position on scrollbar
+ int correction; // scrollbar position correction
};
struct GadgetWheelArea
{
- int x, y; /* active area for wheel (start) */
- int width, height; /* active area for wheel (size) */
+ int x, y; // active area for wheel (start)
+ int width, height; // active area for wheel (size)
};
struct GadgetInfo
{
- boolean deactivated; /* flag to deactivate gadget */
-
- int id; /* internal gadget identifier */
- int image_id; /* internal gadget image identifier */
- int custom_id; /* custom gadget identifier */
- int custom_type_id; /* custom gadget type identifier */
- char info_text[MAX_INFO_TEXTSIZE + 1];/* short popup info text */
- int x, y; /* gadget position */
- int width, height; /* gadget size */
- unsigned int type; /* type (button, text input, ...) */
- unsigned int state; /* state (pressed, released, ...) */
- boolean checked; /* check/radio button state */
- int radio_nr; /* number of radio button series */
- boolean mapped; /* gadget is mapped on the screen */
- boolean active; /* gadget is active */
- boolean direct_draw; /* directly draw to frontbuffer */
- boolean callback_action_always; /* also callback if gadget unchanged */
- int font; /* font to use when inactive */
- int font_active; /* font to use when active */
- int font_unselectable; /* font to use when unselectable */
- struct GadgetBorder border; /* gadget border design */
- struct GadgetDesign design[2]; /* 0: normal; 1: pressed */
- struct GadgetDesign alt_design[2]; /* alternative design */
- struct GadgetDecoration deco; /* decoration on top of gadget */
- unsigned int event_mask; /* possible events for this gadget */
- struct GadgetEvent event; /* actual gadget event */
- gadget_function callback_info; /* function for pop-up info text */
- gadget_function callback_action; /* function for gadget action */
- struct GadgetDrawingArea drawing; /* fields for drawing area gadget */
- struct GadgetTextButton textbutton; /* fields for text button gadget */
- struct GadgetTextInput textinput; /* fields for text input gadget */
- struct GadgetTextArea textarea; /* fields for text area gadget */
- struct GadgetSelectbox selectbox; /* fields for selectbox gadget */
- struct GadgetScrollbar scrollbar; /* fields for scrollbar gadget */
- struct GadgetWheelArea wheelarea; /* fields for scroll wheel area */
- struct GadgetInfo *next; /* next list entry */
+ boolean deactivated; // flag to deactivate gadget
+
+ int id; // internal gadget identifier
+ int image_id; // internal gadget image identifier
+ int custom_id; // custom gadget identifier
+ int custom_type_id; // custom gadget type identifier
+ char info_text[MAX_INFO_TEXTSIZE + 1];// short popup info text
+ int x, y; // gadget position
+ int orig_x, orig_y; // gadget position (original)
+ int width, height; // gadget size
+ unsigned int type; // type (button, text input, ...)
+ unsigned int state; // state (pressed, released, ...)
+ boolean checked; // check/radio button state
+ int radio_nr; // number of radio button series
+ boolean mapped; // gadget is mapped on the screen
+ boolean active; // gadget is active
+ boolean direct_draw; // directly draw to frontbuffer
+ boolean overlay_touch_button; // gadget is overlay touch button
+ int overlay_touch_button_alpha; // overlay touch button alpha value
+ boolean callback_action_always; // also callback if gadget unchanged
+ int font; // font to use when inactive
+ int font_active; // font to use when active
+ int font_unselectable; // font to use when unselectable
+ struct GadgetBorder border; // gadget border design
+ struct GadgetDesign design[2]; // 0: normal; 1: pressed
+ struct GadgetDesign alt_design[2]; // alternative design
+ struct GadgetDecoration deco; // decoration on top of gadget
+ unsigned int event_mask; // possible events for this gadget
+ struct GadgetEvent event; // actual gadget event
+ gadget_function callback_info; // function for pop-up info text
+ gadget_function callback_action; // function for gadget action
+ struct GadgetDrawingArea drawing; // fields for drawing area gadget
+ struct GadgetTextButton textbutton; // fields for text button gadget
+ struct GadgetTextInput textinput; // fields for text input gadget
+ struct GadgetTextArea textarea; // fields for text area gadget
+ struct GadgetSelectbox selectbox; // fields for selectbox gadget
+ struct GadgetScrollbar scrollbar; // fields for scrollbar gadget
+ struct GadgetWheelArea wheelarea; // fields for scroll wheel area
+ struct GadgetInfo *next; // next list entry
};
void UnmapAllGadgets(void);
void RemapAllGadgets(void);
+void SetGadgetsPosition_OverlayTouchButtons(void);
+void DrawGadgets_OverlayTouchButtons(void);
+boolean CheckPosition_OverlayTouchButtons(int, int, int);
+
boolean anyTextInputGadgetActive(void);
boolean anyTextAreaGadgetActive(void);
boolean anySelectboxGadgetActive(void);
void DumpGadgetIdentifiers(void);
boolean DoGadgetAction(int);
-#endif /* GADGETS_H */
+#endif // GADGETS_H