1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00

Add knob_area ext

This commit is contained in:
Adam Martini 2020-06-20 16:47:23 -07:00
parent 5a0c0e2e97
commit 71f8497ee6
2 changed files with 6 additions and 3 deletions

View File

@ -344,14 +344,14 @@ static lv_res_t lv_rotary_signal(lv_obj_t * rotary, lv_signal_t sign, void * par
else if(sign == LV_SIGNAL_PRESSING && ext->last_drag_x != NULL) { else if(sign == LV_SIGNAL_PRESSING && ext->last_drag_x != NULL) {
lv_indev_get_point(param, &p); lv_indev_get_point(param, &p);
if (ext->right_knob_area.y1 < p.y && p.y < ext->right_knob_area.y2) { if (ext->knob_area.y1 < p.y && p.y < ext->knob_area.y2) {
if (p.x > ext->last_drag_x && p.x < ext->right_knob_area.x2) { if (p.x > ext->last_drag_x && p.x < ext->knob_area.x2) {
ext->last_drag_x = p.x; ext->last_drag_x = p.x;
lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) + 1, LV_ANIM_ON); lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) + 1, LV_ANIM_ON);
res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL); res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL);
if(res != LV_RES_OK) return res; if(res != LV_RES_OK) return res;
} }
else if (p.x < ext->last_drag_x && p.x > ext->right_knob_area.x1) { else if (p.x < ext->last_drag_x && p.x > ext->knob_area.x1) {
ext->last_drag_x = p.x; ext->last_drag_x = p.x;
lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) - 1, LV_ANIM_ON); lv_rotary_set_value(rotary, lv_rotary_get_value(rotary) - 1, LV_ANIM_ON);
res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL); res = lv_event_send(rotary, LV_EVENT_VALUE_CHANGED, NULL);
@ -445,6 +445,8 @@ static void draw_knob(lv_obj_t * rotary, const lv_area_t * clip_area)
lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc); lv_draw_rect(&knob_area, clip_area, &knob_rect_dsc);
} }
lv_area_copy(&ext->knob_area, &knob_area);
} }
#endif #endif

View File

@ -63,6 +63,7 @@ typedef struct {
lv_arc_ext_t arc; lv_arc_ext_t arc;
/*New data for this type*/ /*New data for this type*/
lv_style_list_t style_knob; /* Style of the knob */ lv_style_list_t style_knob; /* Style of the knob */
lv_area_t knob_area; /* Area of the knob */
int16_t cur_value; /*Current value of the rotary*/ int16_t cur_value; /*Current value of the rotary*/
int16_t min_value; /*Minimum value of the rotary*/ int16_t min_value; /*Minimum value of the rotary*/
int16_t max_value; /*Maximum value of the rotary*/ int16_t max_value; /*Maximum value of the rotary*/