|
发表于 2021-8-4 11:12:15
|
显示全部楼层
circular gauge 目前只支持一个指针,可以通过重写circular gauge draw实现多指针。
示例:
INT second_needle_angle = 60;
VOID custom_circular_gauge_draw(GX_CIRCULAR_GAUGE *gauge)
{
GX_CIRCULAR_GAUGE_INFO *info;
INT xcor;
INT ycor;
INT needle_xpos;
INT needle_ypos;
GX_PIXELMAP *needle;
GX_PIXELMAP needle_rotated;
/* Call default circular draw. */
gx_circular_gauge_draw(gauge);
/* Pick up pointer to the gauge information structure. */
info = &gauge->gx_circular_gauge_info;
/* Retrieve the map for the second needle. */
gx_context_pixelmap_get(GX_PIXELMAP_ID_NEEDLE, &needle);
if (needle)
{
xcor = (INT)(info->gx_circular_gauge_info_needle_xcor);
ycor = (INT)(info->gx_circular_gauge_info_needle_ycor);
needle_xpos = info->gx_circular_gauge_info_needle_xpos;
needle_ypos = info->gx_circular_gauge_info_needle_ypos;
/* Rotate the second needle pixelmap. */
if (gx_utility_pixelmap_rotate(needle, second_needle_angle, &needle_rotated, &xcor, &ycor) == GX_SUCCESS)
{
/* Calculate start position of needle pixelmap. */
needle_xpos = gauge->gx_widget_size.gx_rectangle_left + info->gx_circular_gauge_info_needle_xpos;
needle_xpos -= xcor;
needle_ypos = gauge->gx_widget_size.gx_rectangle_top + info->gx_circular_gauge_info_needle_ypos;
needle_ypos -= ycor;
/* Draw needle . */
_gx_canvas_pixelmap_draw((GX_VALUE)needle_xpos, (GX_VALUE)needle_ypos, &needle_rotated);
/* Free rotate needle pixelmap memory. */
if (memory_free)
{
if (needle_rotated.gx_pixelmap_aux_data)
{
memory_free((VOID*)needle_rotated.gx_pixelmap_aux_data);
}
memory_free((VOID*)needle_rotated.gx_pixelmap_data);
}
}
}
}
这段代码可以放在tutorials/demo_guix_circular_gauge里使用,需要把表盘的draw函数设为custom_circular_gauge_draw。 |
|