#pragma once #include typedef enum { TOUCH_SWIPE_LEFT, TOUCH_SWIPE_RIGHT } TouchSwipeDir; typedef struct { void (*on_tap)(GPoint point, void *ctx); void (*on_hold)(GPoint point, void *ctx); void (*on_swipe)(TouchSwipeDir dir, void *ctx); void (*on_pan_move)(GPoint delta_since_start, void *ctx); void (*on_pan_end)(bool cancelled, void *ctx); void *ctx; } TouchHandlers; void touch_init(void); void touch_deinit(void); void touch_attach(Window *window, const TouchHandlers *handlers); void touch_detach(Window *window); static inline int16_t touch_menu_row_at(int16_t y, int16_t menu_top, int16_t header_h, int16_t row_h, int16_t scroll_offset_y) { int16_t content_y = (int16_t)(y - menu_top - scroll_offset_y - header_h); return content_y < 0 ? -1 : (int16_t)(content_y / row_h); }