improve progress circle

This commit is contained in:
lixianjing 2021-01-18 12:19:08 +08:00
parent 0182348a70
commit 6af7b79e81
7 changed files with 47 additions and 37 deletions

View File

@ -715,7 +715,7 @@ void nvgLineCap(NVGcontext* ctx, int cap)
{
NVGstate* state = nvg__getState(ctx);
state->lineCap = cap;
if(ctx->params.setLineJoin != NULL)
if(ctx->params.setLineCap != NULL)
{
ctx->params.setLineCap(ctx->params.userPtr, cap);
}

View File

@ -3,10 +3,10 @@
<progress_circle max="360" show_text="true" line_cap="square"
animation="value(from=0, to=360, yoyo_times=1000, duration=3000, easing=sin_inout)" />
<progress_circle max="360" show_text="true" start_angle="90" line_cap="square"
<progress_circle max="360" show_text="true" start_angle="90" line_cap="butt"
animation="value(from=0, to=300, yoyo_times=1000, duration=3000, easing=sin_inout)" />
<progress_circle style="image" max="360" show_text="true" start_angle="-213"
<progress_circle style="image" max="360" show_text="true" start_angle="-213" line_cap="round"
animation="value(from=0, to=300, yoyo_times=1000, duration=3000, easing=sin_inout)" />
<progress_circle style="image" max="100" show_text="true" start_angle="90" start_angle="-225"

View File

@ -1,5 +1,5 @@
TK_CONST_DATA_ALIGN(const unsigned char ui_progress_circle[]) = {
0x04,0x00,0x01,0x01,0x37,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,
0x04,0x00,0x01,0x01,0x35,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,
0x5f,0x63,0x69,0x72,0x63,0x6c,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -23,36 +23,36 @@ TK_CONST_DATA_ALIGN(const unsigned char ui_progress_circle[]) = {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x6d,0x61,0x78,0x00,0x33,0x36,0x30,0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,0x78,0x74,
0x00,0x74,0x72,0x75,0x65,0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,0x39,0x30,
0x00,0x6c,0x69,0x6e,0x65,0x5f,0x63,0x61,0x70,0x00,0x73,0x71,0x75,0x61,0x72,0x65,0x00,0x61,0x6e,0x69,
0x6d,0x61,0x74,0x69,0x6f,0x6e,0x00,0x76,0x61,0x6c,0x75,0x65,0x28,0x66,0x72,0x6f,0x6d,0x3d,0x30,0x2c,
0x20,0x74,0x6f,0x3d,0x33,0x30,0x30,0x2c,0x20,0x79,0x6f,0x79,0x6f,0x5f,0x74,0x69,0x6d,0x65,0x73,0x3d,
0x31,0x30,0x30,0x30,0x2c,0x20,0x64,0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3d,0x33,0x30,0x30,0x30,0x2c,
0x20,0x65,0x61,0x73,0x69,0x6e,0x67,0x3d,0x73,0x69,0x6e,0x5f,0x69,0x6e,0x6f,0x75,0x74,0x29,0x00,0x00,
0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,0x5f,0x63,0x69,0x72,0x63,0x6c,0x65,0x00,0x00,0x00,0x00,
0x00,0x6c,0x69,0x6e,0x65,0x5f,0x63,0x61,0x70,0x00,0x62,0x75,0x74,0x74,0x00,0x61,0x6e,0x69,0x6d,0x61,
0x74,0x69,0x6f,0x6e,0x00,0x76,0x61,0x6c,0x75,0x65,0x28,0x66,0x72,0x6f,0x6d,0x3d,0x30,0x2c,0x20,0x74,
0x6f,0x3d,0x33,0x30,0x30,0x2c,0x20,0x79,0x6f,0x79,0x6f,0x5f,0x74,0x69,0x6d,0x65,0x73,0x3d,0x31,0x30,
0x30,0x30,0x2c,0x20,0x64,0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3d,0x33,0x30,0x30,0x30,0x2c,0x20,0x65,
0x61,0x73,0x69,0x6e,0x67,0x3d,0x73,0x69,0x6e,0x5f,0x69,0x6e,0x6f,0x75,0x74,0x29,0x00,0x00,0x00,0x70,
0x72,0x6f,0x67,0x72,0x65,0x73,0x73,0x5f,0x63,0x69,0x72,0x63,0x6c,0x65,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,
0x00,0x6d,0x61,0x78,0x00,0x33,0x36,0x30,0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,0x78,0x74,0x00,0x74,
0x72,0x75,0x65,0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,0x2d,0x32,0x31,0x33,
0x00,0x61,0x6e,0x69,0x6d,0x61,0x74,0x69,0x6f,0x6e,0x00,0x76,0x61,0x6c,0x75,0x65,0x28,0x66,0x72,0x6f,
0x6d,0x3d,0x30,0x2c,0x20,0x74,0x6f,0x3d,0x33,0x30,0x30,0x2c,0x20,0x79,0x6f,0x79,0x6f,0x5f,0x74,0x69,
0x6d,0x65,0x73,0x3d,0x31,0x30,0x30,0x30,0x2c,0x20,0x64,0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3d,0x33,
0x30,0x30,0x30,0x2c,0x20,0x65,0x61,0x73,0x69,0x6e,0x67,0x3d,0x73,0x69,0x6e,0x5f,0x69,0x6e,0x6f,0x75,
0x74,0x29,0x00,0x00,0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,0x5f,0x63,0x69,0x72,0x63,0x6c,0x65,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,0x61,0x67,0x65,0x00,0x6d,
0x61,0x78,0x00,0x33,0x36,0x30,0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,0x78,0x74,0x00,0x74,0x72,0x75,
0x65,0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,0x2d,0x32,0x31,0x33,0x00,0x61,
0x6e,0x69,0x6d,0x61,0x74,0x69,0x6f,0x6e,0x00,0x76,0x61,0x6c,0x75,0x65,0x28,0x66,0x72,0x6f,0x6d,0x3d,
0x30,0x2c,0x20,0x74,0x6f,0x3d,0x33,0x30,0x30,0x2c,0x20,0x79,0x6f,0x79,0x6f,0x5f,0x74,0x69,0x6d,0x65,
0x73,0x3d,0x31,0x30,0x30,0x30,0x2c,0x20,0x64,0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3d,0x33,0x30,0x30,
0x30,0x2c,0x20,0x65,0x61,0x73,0x69,0x6e,0x67,0x3d,0x73,0x69,0x6e,0x5f,0x69,0x6e,0x6f,0x75,0x74,0x29,
0x00,0x00,0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,0x5f,0x63,0x69,0x72,0x63,0x6c,0x65,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,
0x6d,0x61,0x67,0x65,0x00,0x6d,0x61,0x78,0x00,0x31,0x30,0x30,0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,
0x78,0x74,0x00,0x74,0x72,0x75,0x65,0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,
0x39,0x30,0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,0x2d,0x32,0x32,0x35,0x00,
0x63,0x6f,0x75,0x6e,0x74,0x65,0x72,0x5f,0x63,0x6c,0x6f,0x63,0x6b,0x5f,0x77,0x69,0x73,0x65,0x00,0x74,
0x72,0x75,0x65,0x00,0x75,0x6e,0x69,0x74,0x00,0x25,0x00,0x61,0x6e,0x69,0x6d,0x61,0x74,0x69,0x6f,0x6e,
0x00,0x76,0x61,0x6c,0x75,0x65,0x28,0x66,0x72,0x6f,0x6d,0x3d,0x31,0x30,0x2c,0x20,0x74,0x6f,0x3d,0x31,
0x30,0x30,0x2c,0x20,0x79,0x6f,0x79,0x6f,0x5f,0x74,0x69,0x6d,0x65,0x73,0x3d,0x31,0x30,0x30,0x30,0x2c,
0x20,0x64,0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3d,0x33,0x30,0x30,0x30,0x2c,0x20,0x65,0x61,0x73,0x69,
0x6e,0x67,0x3d,0x73,0x69,0x6e,0x5f,0x69,0x6e,0x6f,0x75,0x74,0x29,0x00,0x00,0x00,0x00,0x62,0x75,0x74,
0x74,0x6f,0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,
0x00,0x1e,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,
0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,
0x6f,0x6d,0x3a,0x31,0x30,0x2c,0x77,0x3d,0x32,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,
0x6d,0x65,0x00,0x63,0x6c,0x6f,0x73,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x73,0x65,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*1127*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,0x61,
0x67,0x65,0x00,0x6d,0x61,0x78,0x00,0x31,0x30,0x30,0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,0x78,0x74,
0x00,0x74,0x72,0x75,0x65,0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,0x39,0x30,
0x00,0x73,0x74,0x61,0x72,0x74,0x5f,0x61,0x6e,0x67,0x6c,0x65,0x00,0x2d,0x32,0x32,0x35,0x00,0x63,0x6f,
0x75,0x6e,0x74,0x65,0x72,0x5f,0x63,0x6c,0x6f,0x63,0x6b,0x5f,0x77,0x69,0x73,0x65,0x00,0x74,0x72,0x75,
0x65,0x00,0x75,0x6e,0x69,0x74,0x00,0x25,0x00,0x61,0x6e,0x69,0x6d,0x61,0x74,0x69,0x6f,0x6e,0x00,0x76,
0x61,0x6c,0x75,0x65,0x28,0x66,0x72,0x6f,0x6d,0x3d,0x31,0x30,0x2c,0x20,0x74,0x6f,0x3d,0x31,0x30,0x30,
0x2c,0x20,0x79,0x6f,0x79,0x6f,0x5f,0x74,0x69,0x6d,0x65,0x73,0x3d,0x31,0x30,0x30,0x30,0x2c,0x20,0x64,
0x75,0x72,0x61,0x74,0x69,0x6f,0x6e,0x3d,0x33,0x30,0x30,0x30,0x2c,0x20,0x65,0x61,0x73,0x69,0x6e,0x67,
0x3d,0x73,0x69,0x6e,0x5f,0x69,0x6e,0x6f,0x75,0x74,0x29,0x00,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,
0x6e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,0x00,0x00,0x00,0x1e,
0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,
0x6c,0x74,0x28,0x78,0x3d,0x63,0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,
0x3a,0x31,0x30,0x2c,0x77,0x3d,0x32,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,
0x00,0x63,0x6c,0x6f,0x73,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x73,0x65,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,};/*1125*/

View File

@ -1247,6 +1247,12 @@ ret_t vgcanvas_set_assets_manager(vgcanvas_t* vg, assets_manager_t* assets_manag
*/
#define VGCANVAS_LINE_CAP_SQUARE "square"
/**
* @const VGCANVAS_LINE_CAP_BUTT
*
*/
#define VGCANVAS_LINE_CAP_BUTT "butt"
/**
* @enum vgcanvas_line_join_t
* @annotation ["scriptable", "string"]

View File

@ -94,9 +94,11 @@ static ret_t progress_circle_on_paint_self(widget_t* widget, canvas_t* c) {
vgcanvas_set_stroke_color(vg, color);
vgcanvas_set_line_width(vg, progress_circle->line_width);
if (tk_str_eq(progress_circle->line_cap, VGCANVAS_LINE_CAP_ROUND)) {
vgcanvas_set_line_cap(vg, progress_circle->line_cap);
} else {
vgcanvas_set_line_cap(vg, VGCANVAS_LINE_CAP_ROUND);
} else if (tk_str_eq(progress_circle->line_cap, VGCANVAS_LINE_CAP_SQUARE)) {
vgcanvas_set_line_cap(vg, VGCANVAS_LINE_CAP_SQUARE);
} else {
vgcanvas_set_line_cap(vg, VGCANVAS_LINE_CAP_BUTT);
}
vgcanvas_begin_path(vg);
if (end_angle > start_angle) {

View File

@ -573,6 +573,8 @@ static ret_t vgcanvas_nanovg_set_line_cap(vgcanvas_t* vgcanvas, const char* valu
line_cap = NVG_ROUND;
} else if (*value == 's') {
line_cap = NVG_SQUARE;
} else if (*value == 'b') {
line_cap = NVG_BUTT;
}
nvgLineCap(vg, line_cap);