From a2655912d488e4d5fdc82d2c1ce1eccf1e73f70f Mon Sep 17 00:00:00 2001 From: CTCaer Date: Sun, 14 Jun 2020 13:13:27 +0300 Subject: [PATCH] nyx: Auto center cursor based on its size --- nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c b/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c index 24cc798..763abf7 100644 --- a/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c +++ b/nyx/nyx_gui/libs/lvgl/lv_core/lv_indev.c @@ -357,7 +357,10 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) if(i->cursor != NULL && (i->proc.last_point.x != data->point.x || i->proc.last_point.y != data->point.y)) { - lv_obj_set_pos(i->cursor, data->point.x, data->point.y); + /*Use cursor's center as pointer*/ + uint32_t off_x = lv_obj_get_width(i->cursor) >> 1; + uint32_t off_y = lv_obj_get_height(i->cursor) >> 1; + lv_obj_set_pos(i->cursor, data->point.x - off_x, data->point.y - off_y); } i->proc.act_point.x = data->point.x;