1# Arc (lv_arc) 2 3## Overview 4 5The Arc consists of a background and a foreground arc. The foreground (indicator) can be touch-adjusted. 6 7## Parts and Styles 8- `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. 9- `LV_PART_INDICATOR` Draws another arc using the *arc* style properties. Its padding values are interpreted relative to the background arc. 10- `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. 11Larger padding makes it larger, smaller padding makes it smaller. 12 13## Usage 14 15### Value and range 16 17A new value can be set using `lv_arc_set_value(arc, new_value)`. 18The value is interpreted in a range (minimum and maximum values) which can be modified with `lv_arc_set_range(arc, min, max)`. 19The default range is 0..100. 20 21The 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. 22To 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)`. 23 24Zero degrees is at the middle right (3 o'clock) of the object and the degrees are increasing in clockwise direction. 25The angles should be in the [0;360] range. 26 27### Rotation 28 29An offset to the 0 degree position can be added with `lv_arc_set_rotation(arc, deg)`. 30 31### Mode 32 33The arc can be one of the following modes: 34- `LV_ARC_MODE_NORMAL` The indicator arc is drawn from the minimum value to the current. 35- `LV_ARC_MODE_REVERSE` The indicator arc is drawn counter-clockwise from the maximum value to the current. 36- `LV_ARC_MODE_SYMMETRICAL` The indicator arc is drawn from the middle point to the current value. 37 38The mode can be set by `lv_arc_set_mode(arc, LV_ARC_MODE_...)` and used only if the angle is set by `lv_arc_set_value()` or the arc is adjusted by finger. 39 40### Change rate 41If the arc is pressed the current value will set with a limited speed according to the set *change rate*. 42The change rate is defined in degree/second unit and can be set with `lv_arc_set_change_rage(arc, rate)` 43 44 45### Setting the indicator manually 46It'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)`. 47In this case the set "value" and "mode" are ignored. 48 49In other words, the angle and value settings are independent. You should exclusively use one or the other. Mixing the two might result in unintended behavior. 50 51To make the arc non-adjustable, remove the style of the knob and make the object non-clickable: 52```c 53lv_obj_remove_style(arc, NULL, LV_PART_KNOB); 54lv_obj_clear_flag(arc, LV_OBJ_FLAG_CLICKABLE); 55``` 56 57### Advanced hit test 58 59If the `LV_OBJ_FLAG_ADV_HITTEST` flag is enabled the arc can be clicked through in the middle. Clicks are recognized only on the ring of the background arc. `lv_obj_set_ext_click_size()` makes the sensitive area larger inside and outside with the given number of pixels. 60 61 62### Place another object to the knob 63 64Another object can be positioned according to the current position of the arc in order to follow the arc's current value (angle). 65To do this use `lv_arc_align_obj_to_angle(arc, obj_to_align, radius_offset)`. 66 67Similarly `lv_arc_rotate_obj_to_angle(arc, obj_to_rotate, radius_offset)` can be used to rotate the object to the current value of the arc. 68 69It's a typical use case to call these functions in the `VALUE_CHANGED` event of the arc. 70 71## Events 72- `LV_EVENT_VALUE_CHANGED` sent when the arc is pressed/dragged to set a new value. 73- `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END` are sent with the following types: 74 - `LV_ARC_DRAW_PART_BACKGROUND` The background arc. 75 - `part`: `LV_PART_MAIN` 76 - `p1`: center of the arc 77 - `radius`: radius of the arc 78 - `arc_dsc` 79 - `LV_ARC_DRAW_PART_FOREGROUND` The foreground arc. 80 - `part`: `LV_PART_INDICATOR` 81 - `p1`: center of the arc 82 - `radius`: radius of the arc 83 - `arc_dsc` 84 - LV_ARC_DRAW_PART_KNOB The knob 85 - `part`: `LV_PART_KNOB` 86 - `draw_area`: the area of the knob 87 - `rect_dsc`: 88 89See the events of the [Base object](/widgets/obj) too. 90 91Learn more about [Events](/overview/event). 92 93## Keys 94- `LV_KEY_RIGHT/UP` Increases the value by one. 95- `LV_KEY_LEFT/DOWN` Decreases the value by one. 96 97 98Learn more about [Keys](/overview/indev). 99 100 101## Example 102 103```eval_rst 104 105.. include:: ../../../examples/widgets/arc/index.rst 106 107``` 108 109## API 110 111```eval_rst 112 113.. doxygenfile:: lv_arc.h 114 :project: lvgl 115 116``` 117