feat(event, widgets) improve the paramter of LV_EVENT_DRAW_PART_BEGIN/END

Add lv_<widget>_draw_part_type_t to widgets to precisly describe the hooked drawings.
Also add class_p element to lv_obj_draw_part_dsc_t to show what widgets lv_<widget>_draw_part_type_t needs to be used.

Related to: https://forum.lvgl.io/t/how-to-add-minor-division-lines-to-a-chart/5366/
This commit is contained in:
Gabor Kiss-Vamosi
2021-07-07 16:18:56 +02:00
parent f172eb3fd7
commit 88c485949f
46 changed files with 712 additions and 349 deletions

View File

@@ -131,16 +131,46 @@ The possible values of `dir` `LV_DIR_NONE/RIGHT/UP/LEFT/DOWN/HOR/VER/ALL` or th
## Events
- `LV_EVENT_VALUE_CHANGED` Sent when a new point is clicked pressed. `lv_chart_get_pressed_point(chart)` returns the zero-based index of the pressed point.
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent for multiple parts. The fields of `lv_obj_draw_part_dsc_t` are set as follows:
- `LV_PART_ITEMS` (the series)
- *Line chart* `clip_area`, `id` (index of the point), `value` (value of `id`th point), `p1`, `p2` (points of the line), `draw_area` (area of the point), `line_dsc`, `rect_dsc`, `sub_part_ptr` (pointer to the series), `part`
- *Bar chart* `clip_area`, `id` (index of the point), `value` (value of `id`th point), `draw_area` (area of the point), `rect_dsc`, `sub_part_ptr` (pointer to the series), `part`
- `LV_PART_TICKS` (major tick lines and label) `clip_area`, `id` (axis), `value` (scaled value of the tick), `text` (`value` converted to decimal), `line_dsc`, `label_dsc`, `part`
- `LV_PART_CURSOR` These events are sent at three times:
- vertical line `clip_area`, `p1`, `p2` (points of the line), `line_dsc`, `part`
- horizontal line `clip_area`, `p1`, `p2` (points of the line), `line_dsc`, `part`
- point `clip_area`, `draw_area` (points of the line), `rect_dsc`, `part`
- `LV_PART_MAIN` (the division lines) `clip_area`, `id` (index of the line), `p1`, `p2` (points of the line), `line_dsc`, `part`. Besides events for every line, an event is sent before the first line and after the last line with `id=0xFFFFFFFF`, `p1 = NULL` and `p2 = NULL`. It can be used to add/remove masks, or draw special division lines.
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent with the following types:
- `LV_CHART_DRAW_PART_DIV_LINE_INIT` Used before/after drawn the div lines to add masks to any extra drawings. The following fields are set:
- `part`: `LV_PART_MAIN`
- `line_dsc`
- `LV_CHART_DRAW_PART_DIV_LINE_HOR`, `LV_CHART_DRAW_PART_DIV_LINE_VER` Used for each horizontal and vertical division lines.
- `part`: `LV_PART_MAIN`
- `id`: index of the line
- `p1`, `p2`: (points of the line
- `line_dsc`
- `LV_CHART_DRAW_PART_LINE_AND_POINT` Used on line and scatter charts for lines and points.
- `part`: `LV_PART_ITEMS`
- `id`: index of the point
- `value`: value of `id`th point
- `p1`, `p2`: points of the line
- `draw_area`: area of the point
- `line_dsc`
- `rect_dsc`
- `sub_part_ptr`: pointer to the series
- `LV_CHART_DRAW_PART_BAR` Used on bar charts for the rectangles.
- `part`: `LV_PART_ITEMS`
- `id`: index of the point
- `value`: value of `id`th point
- `draw_area`: area of the point
- `rect_dsc`:
- `sub_part_ptr`: pointer to the series
- `LV_CHART_DRAW_PART_CURSOR` Used on cursor lines and points.
- `part`: `LV_PART_CURSOR`
- `p1`, `p2`: points of the line
- `line_dsc`
- `rect_dsc`
- `draw_area`: area of the points
- `LV_CHART_DRAW_PART_TICK_LABEL` Used on tick lines and labels.
- `part`: `LV_PART_TICKS`
- `id`: axis
- `value`: value of the tick
- `text`: `value` converted to decimal or `NULL` for minor ticks
- `line_dsc`,
- `label_dsc`,
See the events of the [Base object](/widgets/obj) too.
Learn more about [Events](/overview/event).

View File

@@ -24,7 +24,14 @@ You can set their brightness with `lv_led_set_bright(led, bright)`. The brightne
Use `lv_led_on(led)` and `lv_led_off(led)` to set the brightness to a predefined ON or OFF value. The `lv_led_toggle(led)` toggles between the ON and OFF state.
## Events
No special event are sent by the LED object.
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` is sent for the following types:
- `LV_LED_DRAW_PART_RECTANGLE` The main rectangle. `LV_OBJ_DRAW_PART_RECTANGLE` is not sent by the base object.
- `part`: `LV_PART_MAIN`
- `rect_dsc`
- `draw_area`: the area of the rectangle
See the events of the [Base object](/widgets/obj) too.
Learn more about [Events](/overview/event).

View File

@@ -63,9 +63,34 @@ If `local` is `false` `color_start` and `color_end` will be mapped to the start
`lv_meter_set_indicator_start_value(meter, inidicator, value)` and `lv_meter_set_indicator_end_value(meter, inidicator, value)` sets the value of the indicator.
## Events
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` is sent for the tick labels to allow overwriting the texts. The following fields of `lv_obj_draw_part_dsc_t` is set:
`clip_area`, `part` (to `LV_PART_TICK`), `id` (the index of the major tick line), `value` (the value of the tick line), `label_dsc`, `text` (value converted to decimal)
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` is sent for the following types:
- `LV_METER_DRAW_PART_ARC` The arc indicator
- `part`: `LV_PART_ITEMS`
- `sub_part_ptr`: pointer to the indicator
- `arc_dsc`
- `radius`: radius of the arc
- `p1` center of the arc
- `LV_METER_DRAW_PART_NEEDLE_LINE` The needle lines
- `part`: `LV_PART_ITEMS`
- `p1`, `p2` points of the line
- `line_dsc`
- `sub_part_ptr`: pointer to the indicator
- `LV_METER_DRAW_PART_NEEDLE_IMG` The needle images
- `part`: `LV_PART_ITEMS`
- `p1`, `p2` points of the line
- `img_dsc`
- `sub_part_ptr`: pointer to the indicator
- `LV_METER_DRAW_PART_TICK` The tick lines and labels
- `part`: `LV_PART_TICKS`
- `value`: the value of the line
- `text`: `value` converted to decimal or `NULL` on minor lines
- `label_dsc`: label draw descriptor or `NULL` on minor lines
- `line_dsc`:
- `id`: the index of the line
See the events of the [Base object](/widgets/obj) too.
Learn more about [Events](/overview/event).
## Keys

View File

@@ -33,6 +33,8 @@ The parts of the Spinbox are identical to the [Text area](/widgets/core/textarea
## Events
- `LV_EVENT_VALUE_CHANGED` Sent when the value has changed.
See the events of the [Text area](/widgets/core/textarea) too.
Learn more about [Events](/overview/event).
## Keys

View File

@@ -19,6 +19,8 @@ To create a spinner use `lv_spinner_create(parent, spin_time, arc_length)`. `spi
## Events
No special events are sent the the Spinner.
See the events of the [Arc](/widgets/core/arc) too.
Learn more about [Events](/overview/event).
## Keys