2021-04-12 18:19:04 +02:00
```eval_rst
.. include:: /header.rst
:github_url: |github_link_base|/widgets/arc.md
```
# Arc (lv_arc)
## Overview
2021-08-26 10:52:39 +02:00
The Arc consists of a background and a foreground arc. The foreground (indicator) can be touch-adjusted.
2021-04-12 18:19:04 +02:00
## Parts and Styles
2021-06-09 15:10:35 +02:00
- `LV_PART_MAIN` Draws a background using the typical background style properties and an arc using the arc style properties. The arc's size and position will respect the *padding* style properties.
2021-08-26 10:52:39 +02:00
- `LV_PART_INDICATOR` Draws another arc using the *arc* style properties. Its padding values are interpreted relative to the background arc.
2021-06-09 15:10:35 +02:00
- `LV_PART_KNOB` Draws a handle on the end of the indicator using all background properties and padding values. With zero padding the knob size is the same as the indicator's width.
2021-04-12 18:19:04 +02:00
Larger padding makes it larger, smaller padding makes it smaller.
## Usage
2021-04-30 10:02:03 +02:00
### Value and range
2021-04-12 18:19:04 +02:00
2021-06-09 15:10:35 +02:00
A new value can be set using `lv_arc_set_value(arc, new_value)` .
2021-04-30 10:02:03 +02:00
The value is interpreted in a range (minimum and maximum values) which can be modified with `lv_arc_set_range(arc, min, max)` .
The default range is 1..100.
2021-04-12 18:19:04 +02:00
2021-06-09 15:10:35 +02:00
The indicator arc is drawn on the main part's arc. This if the value is set to maximum the indicator arc will cover the entire "background" arc.
To set the start and end angle of the background arc use the `lv_arc_set_bg_angles(arc, start_angle, end_angle)` functions or `lv_arc_set_bg_start/end_angle(arc, angle)` .
2021-04-30 10:02:03 +02:00
2021-06-09 15:10:35 +02:00
Zero degrees is at the middle right (3 o'clock) of the object and the degrees are increasing in clockwise direction.
The angles should be in the [0;360] range.
2021-04-12 18:19:04 +02:00
### Rotation
An offset to the 0 degree position can added with `lv_arc_set_rotation(arc, deg)` .
2021-04-30 10:02:03 +02:00
### Mode
2021-04-12 18:19:04 +02:00
2021-04-30 10:02:03 +02:00
The arc can be one of the following modes:
- `LV_ARC_MODE_NORMAL` The indicator arc is drawn from the minimimum value to the current.
2021-06-09 15:10:35 +02:00
- `LV_ARC_MODE_REVERSE` The indicator arc is drawn counter-clockwise from the maximum value to the current.
2021-04-30 10:02:03 +02:00
- `LV_ARC_MODE_SYMMETRICAL` The indicator arc is drawn from the middle point to the current value.
2021-04-12 18:19:04 +02:00
2021-04-30 10:02:03 +02:00
The mode can be set by `lv_arc_set_mode(arc, LV_ARC_MODE_...)` and used only if the the angle is set by `lv_arc_set_value()` or the arc is adjusted by finger.
2021-04-12 18:19:04 +02:00
2021-04-30 10:02:03 +02:00
### Change rate
2021-06-09 15:10:35 +02:00
If the arc is pressed the current value will set with a limited speed according to the set *change rate* .
2021-04-30 10:02:03 +02:00
The change rate is defined in degree/second unit and can be set with `lv_arc_set_change_rage(arc, rate)`
2021-04-12 18:19:04 +02:00
2021-04-30 10:02:03 +02:00
### Setting the indicator manually
2021-08-26 10:52:39 +02:00
It's also possible to set the angles of the indicator arc directly with `lv_arc_set_angles(arc, start_angle, end_angle)` function or `lv_arc_set_start/end_angle(arc, start_angle)` .
In this case the set "value" and "mode" are ignored.
2021-04-12 18:19:04 +02:00
2021-08-26 10:52:39 +02:00
In other words, settings angles and values are independent. You should use either value or angle settings. Mixing the two might result in unintended behavior.
2021-04-30 10:02:03 +02:00
2021-08-26 10:52:39 +02:00
To make the arc non-adjustable, remove the style of the knob and make the object non-clickable:
2021-04-30 10:02:03 +02:00
```c
lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE);
```
2021-04-12 18:19:04 +02:00
## Events
2021-04-30 10:02:03 +02:00
- `LV_EVENT_VALUE_CHANGED` sent when the arc is pressed/dragged to set a new value.
2021-07-07 16:18:56 +02:00
- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent with the following types:
- `LV_ARC_DRAW_PART_BACKGROUND` The background arc.
- `part` : `LV_PART_MAIN`
- `p1` : center of the arc
- `radius` : radius of the arc
- `arc_dsc`
- `LV_ARC_DRAW_PART_FOREGROUND` The foreground arc.
- `part` : `LV_PART_INDICATOR`
- `p1` : center of the arc
- `radius` : radius of the arc
- `arc_dsc`
- LV_ARC_DRAW_PART_KNOB The knob
- `part` : `LV_PART_KNOB`
2021-08-24 14:51:29 +02:00
- `draw_area` : the area of the knob
2021-07-07 16:18:56 +02:00
- `rect_dsc` :
See the events of the [Base object ](/widgets/obj ) too.
2021-04-12 18:19:04 +02:00
Learn more about [Events ](/overview/event ).
## Keys
2021-04-30 10:02:03 +02:00
- `LV_KEY_RIGHT/UP` Increases the value by one.
- `LV_KEY_LEFT/DOWN` Decreases the value by one.
2021-04-12 18:19:04 +02:00
Learn more about [Keys ](/overview/indev ).
## Example
```eval_rst
2021-05-03 17:32:57 +02:00
.. include:: ../../../examples/widgets/arc/index.rst
2021-04-12 18:19:04 +02:00
```
## API
```eval_rst
.. doxygenfile:: lv_arc.h
:project: lvgl
```