Arc(圆弧 ) (lv_arc)
Overview(概述)
显示原文
The Arc consists of a background and a foreground arc. The foreground (indicator) can be touch-adjusted.
圆弧由背景弧和前景弧组成。前景(指示器)部分可以通过触摸进行调节。
Parts and Styles(部分和样式)
显示原文
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.LV_PART_INDICATOR
Draws another arc using the arc style properties. Its padding values are interpreted relative to the background arc.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. Larger padding makes it larger, smaller padding makes it smaller.
LV_PART_MAIN
使用典型背景样式属性绘制背景,并使用圆弧样式属性绘制圆弧。圆弧的大小和位置遵循填充(padding)样式属性。LV_PART_INDICATOR
使用圆弧(arc)样式属性绘制出来的另一条圆弧。它的填充值是相对于背景弧来解释的。LV_PART_KNOB
使用所有背景属性和填充值在指示器的末端绘制一个旋钮。当填充值为零时,旋钮大小与指示器的宽度相同。填充值越大,旋钮越大;填充值越小,旋钮越小。
Usage(用法)
Value and range(值和范围)
显示原文
A new value can be set using lv_arc_set_value(arc, new_value). 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 0..100.
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 any of these functions:
lv_arc_set_bg_start_angle(arc, angle)
lv_arc_set_bg_end_angle(arc, angle)
lv_arc_set_bg_angles(arc, start_angle, end_angle)
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.
可以使用 lv_arc_set_value(arc, new_value) 设置新值。设置的值在一个范围(最小值和最大值)内解读,这个范围可以使用 lv_arc_set_range(arc, min, max) 修改。默认范围为 0...100。
指示弧绘制在主体部分的弧线上。也就是说,如果将值设置为最大值,指示弧将会覆盖整个 “背景” 弧线。要设置背景弧的起始角和终止角,可以使用以下任意函数:
lv_arc_set_bg_start_angle(arc, angle)
lv_arc_set_bg_end_angle(arc, angle)
lv_arc_set_bg_angles(arc, start_angle, end_angle)
零度位于对象的右侧(3 点钟方向),度数按顺时针方向递增。角度应在[0;360] 范围内。
Rotation(旋转)
显示原文
An offset to the 0 degree position can be added with lv_arc_set_rotation(arc, deg).
可以用 lv_arc_set_rotation(arc, deg) 从零度位置开始设置角度。
Mode(模式)
显示原文
The arc can be one of the following modes:
LV_ARC_MODE_NORMAL
Indicator arc is drawn clockwise from minimum to current value.LV_ARC_MODE_REVERSE
Indicator arc is drawn counter-clockwise from maximum to current value.LV_ARC_MODE_SYMMETRICAL
Indicator arc is drawn from middle point to current value.
The mode can be set by lv_arc_set_mode(arc, LV_ARC_MODE_...) and
has no effect until angle is set by lv_arc_set_value()
or value of the arc
is changed by pointer input (finger, mouse, etc.).
弧线可以是以下模式之一:
LV_ARC_MODE_NORMAL
普通模式。指示弧从最小值开始按顺时针方向绘制到当前值。LV_ARC_MODE_REVERSE
反向模式。指示弧从最大值开始按逆时针方向绘制到当前值。LV_ARC_MODE_SYMMETRICAL
对称模式。指示弧从中间点绘制到当前值。
可以通过 :cpp:expr:lv_arc_set_mode(arc, LV_ARC_MODE_...) 来设置模式,并且在通过 :cpp:func:lv_arc_set_value 设置角度或者通过指针输入(手指、鼠标等)改变弧线的值之前,设置模式是不起作用的。
Change rate(变化率)
显示原文
When the arc's value is changed by pointer input (finger, mouse, etc.), the rate of its change is limited according to its change rate. Change rate is defined in degrees/second units and can be set with lv_arc_set_change_rage(arc, rate)
当通过指针输入(手指、鼠标等)改变弧线的值时,其变化速率会根据它的 “变化率” 受到限制。变化率是以度 / 秒为单位来定义的,并且可以通过以下方式进行设置: lv_arc_set_change_rage(arc, rate) 设置。(简单的理解就是arc的前景弧到达某个值所需要的时间,时间单位是 度/秒)
Knob offset(旋钮偏移)
显示原文
Changing the knob offset allows the location of the knob to be moved
relative to the end of the arc. The knob offset can be set by
lv_arc_set_knob_offset(arc, offset_angle), and will only be visible if
LV_PART_KNOB
is visible.
改变旋钮偏移量可以使旋钮的位置相对于弧线末端进行移动。旋钮偏移量可以通过 :cpp:expr:lv_arc_set_knob_offset(arc, offset_angle) 来设置,并且只有在 :cpp:enumerator:LV_PART_KNOB(旋钮部件)可见的情况下才会显示出来。
Setting indicator programmatically(以编程方式设置指示器)
显示原文
It is possible to set indicator angle directly with any of these functions:
lv_arc_set_start_angle(arc, start_angle)
lv_arc_set_end_angle(arc, end_angle)
lv_arc_set_angles(arc, start_angle, end_angle)
When used, "value" and "mode" are ignored.
In other words, the angle and value settings are independent. You should exclusively use one or the other of the two methods. Mixing the two could result in unintended behavior.
To make the arc non-adjustable by external input, remove the style of the knob and make the Widget non-clickable:
可以使用以下任意函数直接设置指示器角度:
lv_arc_set_start_angle(arc, start_angle) 设置弧的起始角度
lv_arc_set_end_angle(arc, end_angle) 设置弧的终止角度
lv_arc_set_angles(arc, start_angle, end_angle) 同时设置弧的起始角度和终止角度
使用这些函数时,“值” 和 “模式” 会被忽略。
换句话说,角度设置和值设置是相互独立的。你应该只选用这两种方法中的一种。将两者混用可能会导致意想不到的行为。
要使弧不能通过外部输入进行调整,可以移除旋钮的样式并使该部件不可点击:
lv_obj_remove_style(arc, NULL, LV_PART_KNOB);
lv_obj_remove_flag(arc, LV_OBJ_FLAG_CLICKABLE);
Interactive area(交互区域)
显示原文
By default LV_OBJ_FLAG_ADV_HITTEST
is disabled which
means the arc's whole area is interactive.
As usual lv_obj_set_ext_click_area()
can be used to increase
the area that will respond to pointer input (touch, mouse, etc.) outside the arc by a
specified number of pixels.
If LV_OBJ_FLAG_ADV_HITTEST
is enabled the arc will be sensitive only
in the range between start and end background angles and on the arc itself (not inside the arc).
In this case ext_click_area
makes the sensitive area ticker both inward and outward.
Additionally, a tolerance of lv_dpx(50) pixels is applied to each angle, extending the
hit-test range along the arc's length.
默认情况下,:cpp:enumerator:`LV_OBJ_FLAG_ADV_HITTEST`(高级命中测试对象标志)是禁用的,这意味着弧线的整个区域都是可交互的。
通常,可以使用 :cpp:func:`lv_obj_set_ext_click_area`(设置扩展点击区域函数)来将弧线外部能响应指针输入(触摸、鼠标等)的区域增加指定的像素数。
如果启用了 LV_OBJ_FLAG_ADV_HITTEST
,那么弧线将仅在起始和终止背景角度之间的范围以及弧线本身(而不是弧线内部)上具有交互敏感性。在这种情况下,``ext_click_area``(扩展点击区域)会使敏感区域向内和向外扩展。
此外,会对每个角度应用 lv_dpx(50) 像素的公差,从而沿着弧线的长度扩展命中测试范围。
Place another Widget on the knob(将另一个部件放置在旋钮上)
显示原文
Anoth