Files
player/Project/Src/MyWin/Window/mywin_touch.h
2025-06-27 00:32:57 +08:00

179 lines
4.1 KiB
C

#ifndef MYWIN_TOUCH_H__
#define MYWIN_TOUCH_H__
//定义触摸缓冲个数
#define TOUCH_NUM 20
typedef struct
{
POINT_Struct start;
POINT_Struct route[TOUCH_NUM];
POINT_Struct end;
int route_num;
int down;
}TouchRouteStruct;
#define TOUCH_SLIDE_NONE 0x00000000
#define TOUCH_SLIDE_LEFT 0x00000001
#define TOUCH_SLIDE_RIGHT 0x00000002
#define TOUCH_SLIDE_UP 0x00000003
#define TOUCH_SLIDE_DOWN 0x00000004
//定义子窗口移动消息
#define TOUCH_CHILD_MOV_START 0x00000003
#define TOUCH_CHILD_MOV_END 0x00000004
struct _WIN_TouchWinStruct;
//触控触发条件
typedef struct
{
RECT_Struct start;//起始点范围,屏幕在这个范围内按下才有效
int slide; //方向,指触发距离的方向
int dis; //触发距离,超过此距离之后即使松开屏幕也自动补全
//用于自动创建子窗口的函数指针
struct _WIN_TouchWinStruct *(*creat)(struct _WIN_TouchWinStruct *);
}TouchConditionStruct;
#define TOUCH_CON_DOWN_INIT(w,h,creat_) \
{\
.start.x=0,\
.start.y=0,\
.start.x_size=w,\
.start.y_size=10,\
.slide=TOUCH_SLIDE_DOWN,\
.dis=(h)/4,\
.creat=creat_,\
}
#define TOUCH_CON_UP_INIT(w,h,creat_) \
{\
.start.x=0,\
.start.y=(h)-10,\
.start.x_size=w,\
.start.y_size=10,\
.slide=TOUCH_SLIDE_UP,\
.dis=(h)/4,\
.creat=creat_,\
}
#define TOUCH_CON_LEFT_INIT(w,h,creat_) \
{\
.start.x=(w)-10,\
.start.y=0,\
.start.x_size=10,\
.start.y_size=h,\
.slide=TOUCH_SLIDE_LEFT,\
.dis=(h)/4,\
.creat=creat_,\
}
#define TOUCH_CON_RIGHT_INIT(w,h,creat_) \
{\
.start.x=0,\
.start.y=0,\
.start.x_size=10,\
.start.y_size=h,\
.slide=TOUCH_SLIDE_RIGHT,\
.dis=(h)/4,\
.creat=creat_,\
}
#define TOUCH_CON_DOWN_PAR(w,h,creat_) &((TouchConditionStruct) TOUCH_CON_DOWN_INIT(w,h,creat_))
#define TOUCH_CON_UP_PAR(w,h,creat_) &((TouchConditionStruct) TOUCH_CON_UP_INIT(w,h,creat_))
#define TOUCH_CON_LEFT_PAR(w,h,creat_) &((TouchConditionStruct) TOUCH_CON_LEFT_INIT(w,h,creat_))
#define TOUCH_CON_RIGHT_PAR(w,h,creat_) &((TouchConditionStruct) TOUCH_CON_RIGHT_INIT(w,h,creat_))
//定义触摸窗口可以自动创建的子窗口个数
#define TOUCHWIN_CHILD_MAX_NUM 4
typedef struct _WIN_TouchWinStruct
{
WIN_WindowStruct win;
// TouchConditionStruct in; //本窗口进入方式
TouchConditionStruct out; //本窗口退出方式
int move_start; //是否触发了退出动作
//本窗口的消息处理函数
void (*msgloop)(struct _WIN_TouchWinStruct *win,WIN_MsgStruct *msg);
int timer_id; //自动补全使用的定时器
struct _WIN_TouchWinStruct *work; //由本窗口控制的窗口指针
TouchConditionStruct work_con; //正在控制的窗口动作
TouchConditionStruct child[TOUCHWIN_CHILD_MAX_NUM];
// struct _WIN_TouchWinStruct *(*child[TOUCHWIN_CHILD_MAX_NUM])(struct _WIN_TouchWinStruct *);
int child_num; //当前可自动创建的子窗口个数
int x_inertia; //x方向的惯性
int y_inertia; //y方向的惯性
int timer_inertia; //惯性定时器
}WIN_TouchWinStruct;
WIN_TouchWinStruct *WIN_CreatTouch (WIN_WindowStruct *base,
void (*msgLoop)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg),
int x,int y,int x_size,int y_size);
int WIN_CreatTouchEx (WIN_TouchWinStruct *win,WIN_WindowStruct *base,
void (*msgLoop)(struct _WIN_WindowStruct *win,WIN_MsgStruct *msg),
int x,int y,int x_size,int y_size);
WIN_TouchWinStruct *WIN_CreatTouchChild(WIN_TouchWinStruct *base);
WIN_TouchWinStruct *WIN_CreatTouchBase(WIN_WindowStruct *base);
//添加滑动时自动创建的子窗口
int TOUCHWIN_AddChild(WIN_TouchWinStruct *touch,TouchConditionStruct *c);
//清空自动创建的子窗口
int TOUCHWIN_ClearChild(WIN_TouchWinStruct *touch);
//设置退出动画
int TOUCHWIN_SetOutCon(WIN_TouchWinStruct *touch,TouchConditionStruct *c);
//默认消息循环
void TOUCHWIN_DefaultMsgLoop(WIN_TouchWinStruct *touch,WIN_MsgStruct *msg);
#endif