mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
fix(indev) use lv_dir_t instead of lv_indev_scroll_dir_t and lv_gesture_dir_t
This commit is contained in:
parent
5f44ff412a
commit
dfe56c856a
@ -221,7 +221,7 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point)
|
||||
}
|
||||
}
|
||||
|
||||
lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
|
||||
lv_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev)
|
||||
{
|
||||
return indev->proc.types.pointer.gesture_dir;
|
||||
}
|
||||
@ -234,7 +234,7 @@ uint32_t lv_indev_get_key(const lv_indev_t * indev)
|
||||
return indev->proc.types.keypad.last_key;
|
||||
}
|
||||
|
||||
lv_indev_scroll_dir_t lv_indev_get_scroll_dir(const lv_indev_t * indev)
|
||||
lv_dir_t lv_indev_get_scroll_dir(const lv_indev_t * indev)
|
||||
{
|
||||
if(indev == NULL) return false;
|
||||
if(indev->driver->type != LV_INDEV_TYPE_POINTER && indev->driver->type != LV_INDEV_TYPE_BUTTON) return false;
|
||||
@ -818,7 +818,8 @@ static void indev_proc_press(lv_indev_proc_t * proc)
|
||||
proc->long_pr_sent = 0;
|
||||
proc->types.pointer.scroll_sum.x = 0;
|
||||
proc->types.pointer.scroll_sum.y = 0;
|
||||
proc->types.pointer.scroll_dir = LV_INDEV_SCROLL_DIR_NONE;
|
||||
proc->types.pointer.scroll_dir = LV_DIR_NONE;
|
||||
proc->types.pointer.gesture_dir = LV_DIR_NONE;
|
||||
proc->types.pointer.gesture_sent = 0;
|
||||
proc->types.pointer.gesture_sum.x = 0;
|
||||
proc->types.pointer.gesture_sum.y = 0;
|
||||
@ -955,7 +956,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev)
|
||||
indev->proc.longpr_rep_timestamp = 0;
|
||||
indev->proc.types.pointer.scroll_sum.x = 0;
|
||||
indev->proc.types.pointer.scroll_sum.y = 0;
|
||||
indev->proc.types.pointer.scroll_dir = LV_INDEV_SCROLL_DIR_NONE;
|
||||
indev->proc.types.pointer.scroll_dir = LV_DIR_NONE;
|
||||
indev->proc.types.pointer.scroll_throw_vect.x = 0;
|
||||
indev->proc.types.pointer.scroll_throw_vect.y = 0;
|
||||
indev->proc.types.pointer.gesture_sum.x = 0;
|
||||
@ -1070,15 +1071,15 @@ void indev_gesture(lv_indev_proc_t * proc)
|
||||
|
||||
if(LV_ABS(proc->types.pointer.gesture_sum.x) > LV_ABS(proc->types.pointer.gesture_sum.y)) {
|
||||
if(proc->types.pointer.gesture_sum.x > 0)
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_RIGHT;
|
||||
proc->types.pointer.gesture_dir = LV_DIR_RIGHT;
|
||||
else
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_LEFT;
|
||||
proc->types.pointer.gesture_dir = LV_DIR_LEFT;
|
||||
}
|
||||
else {
|
||||
if(proc->types.pointer.gesture_sum.y > 0)
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_BOTTOM;
|
||||
proc->types.pointer.gesture_dir = LV_DIR_BOTTOM;
|
||||
else
|
||||
proc->types.pointer.gesture_dir = LV_GESTURE_DIR_TOP;
|
||||
proc->types.pointer.gesture_dir = LV_DIR_TOP;
|
||||
}
|
||||
|
||||
lv_event_send(gesture_obj, LV_EVENT_GESTURE, indev_act);
|
||||
|
@ -99,7 +99,7 @@ void lv_indev_get_point(const lv_indev_t * indev, lv_point_t * point);
|
||||
* @param indev pointer to an input device
|
||||
* @return current gesture direct
|
||||
*/
|
||||
lv_gesture_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev);
|
||||
lv_dir_t lv_indev_get_gesture_dir(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Get the last pressed key of an input device (for LV_INDEV_TYPE_KEYPAD)
|
||||
@ -112,10 +112,10 @@ uint32_t lv_indev_get_key(const lv_indev_t * indev);
|
||||
* Check the current scroll direction of an input device (for LV_INDEV_TYPE_POINTER and
|
||||
* LV_INDEV_TYPE_BUTTON)
|
||||
* @param indev pointer to an input device
|
||||
* @return LV_SCROLL_DIR_NONE: no scrolling now
|
||||
* LV_SCROLL_DIR_HOR/VER
|
||||
* @return LV_DIR_NONE: no scrolling now
|
||||
* LV_DIR_HOR/VER
|
||||
*/
|
||||
lv_indev_scroll_dir_t lv_indev_get_scroll_dir(const lv_indev_t * indev);
|
||||
lv_dir_t lv_indev_get_scroll_dir(const lv_indev_t * indev);
|
||||
|
||||
/**
|
||||
* Get the currently scrolled object (for LV_INDEV_TYPE_POINTER and
|
||||
|
@ -65,7 +65,7 @@ void _lv_indev_scroll_handler(lv_indev_proc_t * proc)
|
||||
lv_coord_t diff_x = 0;
|
||||
lv_coord_t diff_y = 0;
|
||||
|
||||
if(proc->types.pointer.scroll_dir == LV_INDEV_SCROLL_DIR_HOR) {
|
||||
if(proc->types.pointer.scroll_dir == LV_DIR_HOR) {
|
||||
lv_coord_t sr = lv_obj_get_scroll_right(scroll_obj);
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(scroll_obj);
|
||||
diff_x = elastic_diff(scroll_obj, proc->types.pointer.vect.x, sl, sr, LV_DIR_HOR);
|
||||
@ -95,7 +95,7 @@ void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc)
|
||||
{
|
||||
lv_obj_t * scroll_obj = proc->types.pointer.scroll_obj;
|
||||
if(scroll_obj == NULL) return;
|
||||
if(proc->types.pointer.scroll_dir == LV_INDEV_SCROLL_DIR_NONE) return;
|
||||
if(proc->types.pointer.scroll_dir == LV_DIR_NONE) return;
|
||||
|
||||
|
||||
lv_indev_t * indev_act = lv_indev_get_act();
|
||||
@ -109,7 +109,7 @@ void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc)
|
||||
lv_scroll_snap_t align_x = lv_obj_get_scroll_snap_x(scroll_obj);
|
||||
lv_scroll_snap_t align_y = lv_obj_get_scroll_snap_y(scroll_obj);
|
||||
|
||||
if(proc->types.pointer.scroll_dir == LV_INDEV_SCROLL_DIR_VER) {
|
||||
if(proc->types.pointer.scroll_dir == LV_DIR_VER) {
|
||||
proc->types.pointer.scroll_throw_vect.x = 0;
|
||||
/*If no snapping "throw"*/
|
||||
if(align_y == LV_SCROLL_SNAP_NONE) {
|
||||
@ -132,7 +132,7 @@ void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc)
|
||||
lv_obj_scroll_by(scroll_obj, 0, diff_y + y, LV_ANIM_ON);
|
||||
}
|
||||
}
|
||||
else if(proc->types.pointer.scroll_dir == LV_INDEV_SCROLL_DIR_HOR) {
|
||||
else if(proc->types.pointer.scroll_dir == LV_DIR_HOR) {
|
||||
proc->types.pointer.scroll_throw_vect.y = 0;
|
||||
/*If no snapping "throw"*/
|
||||
if(align_x == LV_SCROLL_SNAP_NONE) {
|
||||
@ -190,7 +190,7 @@ void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc)
|
||||
lv_event_send(scroll_obj, LV_EVENT_SCROLL_END, indev_act);
|
||||
if(proc->reset_query) return;
|
||||
|
||||
proc->types.pointer.scroll_dir = LV_INDEV_SCROLL_DIR_NONE;
|
||||
proc->types.pointer.scroll_dir = LV_DIR_NONE;
|
||||
proc->types.pointer.scroll_obj = NULL;
|
||||
}
|
||||
}
|
||||
@ -297,7 +297,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc)
|
||||
(down_en && proc->types.pointer.scroll_sum.y <= - scroll_limit)))
|
||||
{
|
||||
obj_candidate = obj_act;
|
||||
dir_candidate = LV_INDEV_SCROLL_DIR_VER;
|
||||
dir_candidate = LV_DIR_VER;
|
||||
}
|
||||
|
||||
if((sl > 0 || sr > 0) &&
|
||||
@ -305,7 +305,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc)
|
||||
(right_en && proc->types.pointer.scroll_sum.x <= - scroll_limit)))
|
||||
{
|
||||
obj_candidate = obj_act;
|
||||
dir_candidate = LV_INDEV_SCROLL_DIR_HOR;
|
||||
dir_candidate = LV_DIR_HOR;
|
||||
}
|
||||
|
||||
if(st <= 0) up_en = false;
|
||||
@ -319,7 +319,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc)
|
||||
(up_en && proc->types.pointer.scroll_sum.y >= scroll_limit) ||
|
||||
(down_en && proc->types.pointer.scroll_sum.y <= - scroll_limit))
|
||||
{
|
||||
proc->types.pointer.scroll_dir = hor_en ? LV_INDEV_SCROLL_DIR_HOR : LV_INDEV_SCROLL_DIR_VER;
|
||||
proc->types.pointer.scroll_dir = hor_en ? LV_DIR_HOR : LV_DIR_VER;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
|
||||
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE) == false) return;
|
||||
|
||||
lv_indev_scroll_dir_t sm = lv_obj_get_scrollbar_mode(obj);
|
||||
lv_dir_t sm = lv_obj_get_scrollbar_mode(obj);
|
||||
if(sm == LV_SCROLLBAR_MODE_OFF) return;
|
||||
|
||||
/*If there is no indev scrolling this object but `mode==active` return*/
|
||||
@ -398,13 +398,13 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(obj);
|
||||
lv_coord_t sr = lv_obj_get_scroll_right(obj);
|
||||
|
||||
lv_indev_scroll_dir_t dir = lv_obj_get_scroll_dir(obj);
|
||||
lv_dir_t dir = lv_obj_get_scroll_dir(obj);
|
||||
|
||||
bool ver_draw = false;
|
||||
if((dir & LV_DIR_VER) &&
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (st > 0 || sb > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_INDEV_SCROLL_DIR_VER))) {
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_VER))) {
|
||||
ver_draw = true;
|
||||
}
|
||||
|
||||
@ -413,7 +413,7 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
|
||||
if((dir & LV_DIR_HOR) &&
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (sl > 0 || sr > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_INDEV_SCROLL_DIR_HOR))) {
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_HOR))) {
|
||||
hor_draw = true;
|
||||
}
|
||||
|
||||
|
@ -59,34 +59,19 @@ struct _lv_indev_t;
|
||||
struct _lv_indev_drv_t;
|
||||
|
||||
/** Possible input device types*/
|
||||
enum {
|
||||
typedef enum {
|
||||
LV_INDEV_TYPE_NONE, /**< Uninitialized state*/
|
||||
LV_INDEV_TYPE_POINTER, /**< Touch pad, mouse, external button*/
|
||||
LV_INDEV_TYPE_KEYPAD, /**< Keypad or keyboard*/
|
||||
LV_INDEV_TYPE_BUTTON, /**< External (hardware button) which is assigned to a specific point of the screen*/
|
||||
LV_INDEV_TYPE_ENCODER, /**< Encoder with only Left, Right turn and a Button*/
|
||||
};
|
||||
typedef uint8_t lv_indev_type_t;
|
||||
} lv_indev_type_t;
|
||||
|
||||
/** States for input devices*/
|
||||
enum { LV_INDEV_STATE_RELEASED = 0, LV_INDEV_STATE_PRESSED };
|
||||
typedef uint8_t lv_indev_state_t;
|
||||
|
||||
enum {
|
||||
LV_INDEV_SCROLL_DIR_NONE,
|
||||
LV_INDEV_SCROLL_DIR_HOR,
|
||||
LV_INDEV_SCROLL_DIR_VER,
|
||||
};
|
||||
|
||||
typedef uint8_t lv_indev_scroll_dir_t;
|
||||
|
||||
enum {
|
||||
LV_GESTURE_DIR_TOP, /**< Gesture dir up.*/
|
||||
LV_GESTURE_DIR_BOTTOM, /**< Gesture dir down.*/
|
||||
LV_GESTURE_DIR_LEFT, /**< Gesture dir left.*/
|
||||
LV_GESTURE_DIR_RIGHT, /**< Gesture dir right.*/
|
||||
};
|
||||
typedef uint8_t lv_gesture_dir_t;
|
||||
typedef enum {
|
||||
LV_INDEV_STATE_RELEASED = 0,
|
||||
LV_INDEV_STATE_PRESSED
|
||||
} lv_indev_state_t;
|
||||
|
||||
/** Data structure passed to an input driver to fill*/
|
||||
typedef struct {
|
||||
@ -171,8 +156,8 @@ typedef struct _lv_indev_proc_t {
|
||||
|
||||
lv_point_t gesture_sum; /*Count the gesture pixels to check LV_INDEV_DEF_GESTURE_LIMIT*/
|
||||
/*Flags*/
|
||||
lv_indev_scroll_dir_t scroll_dir : 2;
|
||||
lv_gesture_dir_t gesture_dir : 2;
|
||||
lv_dir_t scroll_dir : 4;
|
||||
lv_dir_t gesture_dir : 4;
|
||||
uint8_t gesture_sent : 1;
|
||||
} pointer;
|
||||
struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user