mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-09 03:51:08 +08:00
improve progress circle
This commit is contained in:
parent
6a902d63df
commit
ae2c97d93f
@ -1,5 +1,5 @@
|
||||
<window >
|
||||
<view x="c" y="m" w="200" h="200" children_layout="default(r=2,c=2,s=5)">
|
||||
<view x="c" y="m" w="200" h="400" children_layout="default(r=4,c=2,s=5)">
|
||||
<progress_circle max="360" show_text="true" line_cap="square"
|
||||
animation="value(from=0, to=360, yoyo_times=1000, duration=3000, easing=sin_inout)" />
|
||||
|
||||
@ -12,6 +12,21 @@
|
||||
<progress_circle style="image" max="100" show_text="true" start_angle="90" start_angle="-225"
|
||||
counter_clock_wise="true" format="%d%%"
|
||||
animation="value(from=10, to=100, yoyo_times=1000, duration=3000, easing=sin_inout)" />
|
||||
|
||||
<progress_circle max="360" show_text="true" line_cap="square" line_width="50"
|
||||
animation="value(from=0, to=360, yoyo_times=1000, duration=3000, easing=sin_inout)" />
|
||||
|
||||
<progress_circle style="image" max="100" show_text="true" start_angle="90" start_angle="-225"
|
||||
format="%d%%" line_width="50"
|
||||
animation="value(from=10, to=100, yoyo_times=1000, duration=3000, easing=sin_inout)" />
|
||||
|
||||
<progress_circle max="360" show_text="true" line_cap="square" line_width="50" value="0"
|
||||
counter_clock_wise="true" animation="value(from=0, to=360, yoyo_times=1000, duration=3000, easing=sin_inout)" />
|
||||
|
||||
<progress_circle style="image" max="100" show_text="true" start_angle="90" start_angle="-225"
|
||||
counter_clock_wise="true" format="%d%%" line_width="50" value="100"
|
||||
animation="value(from=10, to=100, yoyo_times=1000, duration=3000, easing=sin_inout)" />
|
||||
|
||||
</view>
|
||||
|
||||
<button name="close" x="center" y="bottom:10" w="25%" h="30" text="Close"/>
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
2024/04/24
|
||||
* 增加函数tk\_skip\_chars/tk\_skip\_to\_chars
|
||||
* 修复progress circle在最大值时没有绘制的问题。
|
||||
* progress circle支持扇形绘制。
|
||||
|
||||
2024/04/23
|
||||
* 去掉拼音输入法中不必要的断言(输入14个z时出现)(感谢颖健提供补丁)
|
||||
|
@ -1,15 +1,15 @@
|
||||
TK_CONST_DATA_ALIGN(const unsigned char ui_progress_circle_default[]) = {
|
||||
0x04,0x00,0x01,0x01,0x49,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x72,0x6f,0x67,0x72,0x65,0x73,0x73,
|
||||
0x04,0x00,0x01,0x01,0xc1,0x07,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,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x69,0x65,
|
||||
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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc8,0x00,0x00,
|
||||
0x00,0xc8,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,
|
||||
0x00,0x90,0x01,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,0x2c,0x79,0x3d,0x6d,0x2c,0x77,0x3d,0x32,0x30,0x30,0x2c,0x68,
|
||||
0x3d,0x32,0x30,0x30,0x29,0x00,0x63,0x68,0x69,0x6c,0x64,0x72,0x65,0x6e,0x5f,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x72,0x3d,0x32,0x2c,0x63,0x3d,0x32,0x2c,0x73,0x3d,
|
||||
0x3d,0x34,0x30,0x30,0x29,0x00,0x63,0x68,0x69,0x6c,0x64,0x72,0x65,0x6e,0x5f,0x6c,0x61,0x79,0x6f,0x75,
|
||||
0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x72,0x3d,0x34,0x2c,0x63,0x3d,0x32,0x2c,0x73,0x3d,
|
||||
0x35,0x29,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,0x6d,0x61,0x78,0x00,0x33,0x36,0x30,0x00,
|
||||
@ -49,11 +49,55 @@ TK_CONST_DATA_ALIGN(const unsigned char ui_progress_circle_default[]) = {
|
||||
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,};/*1145*/
|
||||
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,0x6d,0x61,0x78,0x00,0x33,0x36,0x30,0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,0x78,0x74,0x00,
|
||||
0x74,0x72,0x75,0x65,0x00,0x6c,0x69,0x6e,0x65,0x5f,0x63,0x61,0x70,0x00,0x73,0x71,0x75,0x61,0x72,0x65,
|
||||
0x00,0x6c,0x69,0x6e,0x65,0x5f,0x77,0x69,0x64,0x74,0x68,0x00,0x35,0x30,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,0x36,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,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,0x66,0x6f,0x72,0x6d,0x61,0x74,
|
||||
0x00,0x25,0x64,0x25,0x25,0x00,0x6c,0x69,0x6e,0x65,0x5f,0x77,0x69,0x64,0x74,0x68,0x00,0x35,0x30,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,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,0x6d,0x61,0x78,0x00,0x33,0x36,0x30,
|
||||
0x00,0x73,0x68,0x6f,0x77,0x5f,0x74,0x65,0x78,0x74,0x00,0x74,0x72,0x75,0x65,0x00,0x6c,0x69,0x6e,0x65,
|
||||
0x5f,0x63,0x61,0x70,0x00,0x73,0x71,0x75,0x61,0x72,0x65,0x00,0x6c,0x69,0x6e,0x65,0x5f,0x77,0x69,0x64,
|
||||
0x74,0x68,0x00,0x35,0x30,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x30,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,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,0x36,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,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,0x66,0x6f,0x72,0x6d,0x61,0x74,0x00,0x25,0x64,0x25,0x25,0x00,0x6c,0x69,0x6e,0x65,0x5f,0x77,0x69,
|
||||
0x64,0x74,0x68,0x00,0x35,0x30,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x31,0x30,0x30,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,};/*2033*/
|
||||
|
Binary file not shown.
@ -57,9 +57,8 @@ static float_t progress_circle_value_to_angle(widget_t* widget, float_t value) {
|
||||
progress_circle_t* progress_circle = PROGRESS_CIRCLE(widget);
|
||||
return_value_if_fail(progress_circle != NULL, 0);
|
||||
|
||||
return tk_value_to_angle(value, 0, progress_circle->max,
|
||||
progress_circle->start_angle, progress_circle->start_angle + 360,
|
||||
progress_circle->counter_clock_wise);
|
||||
return tk_value_to_angle(value, 0, progress_circle->max, progress_circle->start_angle,
|
||||
progress_circle->start_angle + 360, progress_circle->counter_clock_wise);
|
||||
}
|
||||
|
||||
static float_t progress_circle_get_radius(widget_t* widget) {
|
||||
@ -192,6 +191,9 @@ static ret_t progress_circle_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
end_angle = start_angle;
|
||||
} else {
|
||||
end_angle = progress_circle_value_to_angle(widget, progress_circle->value);
|
||||
if (progress_circle->value == progress_circle->max) {
|
||||
end_angle = start_angle + M_PI * 2;
|
||||
}
|
||||
}
|
||||
|
||||
vgcanvas_save(vg);
|
||||
@ -206,12 +208,29 @@ static ret_t progress_circle_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
vgcanvas_set_line_cap(vg, VGCANVAS_LINE_CAP_BUTT);
|
||||
}
|
||||
vgcanvas_begin_path(vg);
|
||||
|
||||
if (end_angle > start_angle) {
|
||||
vgcanvas_arc(vg, cx, cy, r, start_angle, end_angle, ccw);
|
||||
if (has_image) {
|
||||
vgcanvas_paint(vg, TRUE, &img);
|
||||
float max_r = tk_min(widget->w, widget->h) / 2;
|
||||
if (progress_circle->line_width > max_r / 2) {
|
||||
//画扇形
|
||||
vgcanvas_set_fill_color(vg, color);
|
||||
vgcanvas_move_to(vg, cx, cy);
|
||||
vgcanvas_line_to(vg, cx + max_r * cos(start_angle), cy + max_r * sin(start_angle));
|
||||
vgcanvas_arc(vg, cx, cy, max_r, start_angle, end_angle, ccw);
|
||||
vgcanvas_close_path(vg);
|
||||
|
||||
if (has_image) {
|
||||
vgcanvas_paint(vg, FALSE, &img);
|
||||
} else {
|
||||
vgcanvas_fill(vg);
|
||||
}
|
||||
} else {
|
||||
vgcanvas_stroke(vg);
|
||||
vgcanvas_arc(vg, cx, cy, r, start_angle, end_angle, ccw);
|
||||
if (has_image) {
|
||||
vgcanvas_paint(vg, TRUE, &img);
|
||||
} else {
|
||||
vgcanvas_stroke(vg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ typedef struct _progress_circle_t {
|
||||
/**
|
||||
* @property {uint32_t} line_width
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* 环线的厚度(缺省为8)。
|
||||
* 环线的厚度(缺省为8),line_width > r/2时,使用扇形绘制。
|
||||
*/
|
||||
uint32_t line_width;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user