refactor(event) change lv_event_get_ext_draw_size_info to lv_event_set_ext_draw_size for simpler usage

This commit is contained in:
Gabor Kiss-Vamosi
2021-05-14 23:56:34 +02:00
parent b56e60acef
commit b7f875aba6
3 changed files with 7 additions and 12 deletions

View File

@@ -214,10 +214,5 @@ So it doesn't matter e.g. if a tabel's cell is masked because the tables backgro
If you need to draw outside of a widget LVGL needs to know about it to provide the extra space for drawing. If you need to draw outside of a widget LVGL needs to know about it to provide the extra space for drawing.
Let's say you create an event the writes the current value of a slider above its knob. In this case LVGL needs to know that the slider's draw area should be larger with the size required for the text. Let's say you create an event the writes the current value of a slider above its knob. In this case LVGL needs to know that the slider's draw area should be larger with the size required for the text.
`lv_event_get_ext_draw_size_info(event)` return a pointer to an `lv_coord_t` variable in which the extra draw size can be set. You can simple set the required draw area with `lv_event_set_ext_draw_size(e, size)`.
Note that, other events also might set the value of this variable so you should set only values larger than the current value. For example:
```c
lv_coord_t * s = lv_event_get_ext_draw_size_info(event);
*s = LV_MAX(*s, 50);
```

View File

@@ -289,13 +289,13 @@ uint32_t lv_event_get_key(lv_event_t * e)
} }
} }
lv_coord_t * lv_event_get_ext_draw_size_info(lv_event_t * e) void lv_event_set_ext_draw_size(lv_event_t * e, lv_coord_t size)
{ {
if(e->code == LV_EVENT_REFR_EXT_DRAW_SIZE) { if(e->code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
return lv_event_get_param(e); lv_coord_t * cur_size = lv_event_get_param(e);
*cur_size = LV_MAX(*cur_size, size);
} else { } else {
LV_LOG_WARN("Not interpreted with this event code"); LV_LOG_WARN("Not interpreted with this event code");
return 0;
} }
} }

View File

@@ -268,11 +268,11 @@ const lv_area_t * lv_event_get_old_size(lv_event_t * e);
uint32_t lv_event_get_key(lv_event_t * e); uint32_t lv_event_get_key(lv_event_t * e);
/** /**
* Get a pointer to an `lv_coord_t` variable in which the new extra draw size should be saved. Can be used in `LV_EVENT_REFR_EXT_DRAW_SIZE` * Set the new extra draw size. Can be used in `LV_EVENT_REFR_EXT_DRAW_SIZE`
* @param e pointer to an event * @param e pointer to an event
* @return pointer to `lv_coord_t` or NULL if called on an unrelated event * @param size The new extra draw size
*/ */
lv_coord_t * lv_event_get_ext_draw_size_info(lv_event_t * e); void lv_event_set_ext_draw_size(lv_event_t * e, lv_coord_t size);
/** /**
* Get a pointer to an `lv_point_t` variable in which the self size should be saved (width in `point->x` and height `point->y`). * Get a pointer to an `lv_point_t` variable in which the self size should be saved (width in `point->x` and height `point->y`).