mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
add bar_size prop for slider
This commit is contained in:
parent
251b4bdc79
commit
3e0c7babe1
@ -365,24 +365,24 @@
|
||||
#include "assets/inc/images/arrow_left_n.data"
|
||||
#include "assets/inc/images/edit_clear_p.data"
|
||||
#include "assets/inc/images/battery_2.data"
|
||||
#endif/*WITH_STB_IMAGE*/
|
||||
#endif /*WITH_STB_IMAGE*/
|
||||
#ifdef WITH_VGCANVAS
|
||||
#include "assets/inc/images/pointer_4.bsvg"
|
||||
#include "assets/inc/images/china.bsvg"
|
||||
#include "assets/inc/images/pointer_1.bsvg"
|
||||
#include "assets/inc/images/pointer.bsvg"
|
||||
#include "assets/inc/images/girl.bsvg"
|
||||
#endif/*WITH_VGCANVAS*/
|
||||
#endif /*WITH_VGCANVAS*/
|
||||
#if defined(WITH_STB_FONT) || defined(WITH_FT_FONT)
|
||||
#ifdef WITH_MINI_FONT
|
||||
#include "assets/inc/fonts/default.mini.res"
|
||||
#else/*WITH_MINI_FONT*/
|
||||
#else /*WITH_MINI_FONT*/
|
||||
#include "assets/inc/fonts/default.res"
|
||||
#endif/*WITH_MINI_FONT*/
|
||||
#else/*WITH_STB_FONT or WITH_FT_FONT*/
|
||||
#endif /*WITH_MINI_FONT*/
|
||||
#else /*WITH_STB_FONT or WITH_FT_FONT*/
|
||||
#include "assets/inc/fonts/default.data"
|
||||
#endif/*WITH_STB_FONT or WITH_FT_FONT*/
|
||||
#endif/*WITH_FS_RES*/
|
||||
#endif /*WITH_STB_FONT or WITH_FT_FONT*/
|
||||
#endif /*WITH_FS_RES*/
|
||||
|
||||
ret_t assets_init(void) {
|
||||
assets_manager_t* rm = assets_manager();
|
||||
@ -639,7 +639,7 @@ ret_t assets_init(void) {
|
||||
assets_manager_add(rm, image_pointer_1);
|
||||
assets_manager_add(rm, image_pointer);
|
||||
assets_manager_add(rm, image_girl);
|
||||
#endif/*WITH_VGCANVAS*/
|
||||
#endif /*WITH_VGCANVAS*/
|
||||
#endif
|
||||
|
||||
tk_init_assets();
|
||||
|
@ -1,5 +1,5 @@
|
||||
const unsigned char ui_vtranslate[] = {
|
||||
0x04,0x00,0x01,0x01,0x2b,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x74,0x72,0x61,0x6e,0x73,0x6c,0x61,
|
||||
0x04,0x00,0x01,0x01,0x38,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x74,0x72,0x61,0x6e,0x73,0x6c,0x61,
|
||||
0x74,0x65,0x00,0x64,0x61,0x74,0x61,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,
|
||||
@ -7,26 +7,26 @@ const unsigned char ui_vtranslate[] = {
|
||||
0x5f,0x68,0x69,0x6e,0x74,0x00,0x76,0x74,0x72,0x61,0x6e,0x73,0x6c,0x61,0x74,0x65,0x00,0x00,0x73,0x6c,
|
||||
0x69,0x64,0x65,0x72,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,0x0a,0x00,0x00,0x00,0x50,0x00,
|
||||
0x00,0x00,0x14,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,
|
||||
0x00,0x00,0x28,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,0x31,0x30,0x2c,
|
||||
0x77,0x3d,0x38,0x30,0x25,0x2c,0x68,0x3d,0x32,0x30,0x29,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x31,0x30,
|
||||
0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,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,0x32,
|
||||
0x00,0x00,0x00,0x50,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,0x35,0x30,0x2c,0x77,0x3d,0x38,0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,0x79,
|
||||
0x6c,0x65,0x00,0x69,0x6d,0x67,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x32,0x30,0x00,0x00,0x00,0x73,0x6c,
|
||||
0x69,0x64,0x65,0x72,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,0x5a,0x00,0x00,0x00,0x50,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,0x39,0x30,0x2c,
|
||||
0x77,0x3d,0x38,0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,
|
||||
0x67,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x33,0x30,0x00,0x6d,0x69,0x6e,0x00,0x35,0x00,0x6d,0x61,0x78,
|
||||
0x00,0x35,0x30,0x00,0x73,0x74,0x65,0x70,0x00,0x35,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,
|
||||
0x77,0x3d,0x38,0x30,0x25,0x2c,0x68,0x3d,0x34,0x30,0x29,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x31,0x30,
|
||||
0x00,0x62,0x61,0x72,0x5f,0x73,0x69,0x7a,0x65,0x00,0x31,0x30,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,
|
||||
0x72,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,0x32,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x3c,
|
||||
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,0x35,0x30,0x2c,0x77,0x3d,0x38,
|
||||
0x30,0x25,0x2c,0x68,0x3d,0x36,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,0x67,0x00,0x76,
|
||||
0x61,0x6c,0x75,0x65,0x00,0x32,0x30,0x00,0x00,0x00,0x73,0x6c,0x69,0x64,0x65,0x72,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,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,};/*603*/
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x3c,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,0x31,0x32,0x30,0x2c,0x77,0x3d,0x38,0x30,0x25,0x2c,0x68,
|
||||
0x3d,0x36,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x69,0x6d,0x67,0x00,0x76,0x61,0x6c,0x75,0x65,
|
||||
0x00,0x33,0x30,0x00,0x6d,0x69,0x6e,0x00,0x35,0x00,0x6d,0x61,0x78,0x00,0x35,0x30,0x00,0x73,0x74,0x65,
|
||||
0x70,0x00,0x35,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,};/*616*/
|
||||
|
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
<window anim_hint="vtranslate">
|
||||
<slider x="center" y="10" w="80%" h="20" value="10"/>
|
||||
<slider style="img" x="center" y="50" w="80%" h="30" value="20" />
|
||||
<slider style="img" x="center" y="90" w="80%" h="30" value="30" min="5" max="50" step="5"/>
|
||||
<slider x="center" y="10" w="80%" h="40" value="10" bar_size="10"/>
|
||||
<slider style="img" x="center" y="50" w="80%" h="60" value="20" />
|
||||
<slider style="img" x="center" y="120" w="80%" h="60" value="30" min="5" max="50" step="5"/>
|
||||
<button name="close" x="center" y="bottom:10" w="25%" h="30" text="Close"/>
|
||||
</window>
|
||||
|
@ -2,6 +2,7 @@
|
||||
* 2019/03/21
|
||||
* 增加lcd\_profile用于对绘制函数进行profile。
|
||||
* data资源支持同文件名,不同扩展名。
|
||||
* slider增加bar\_size属性。
|
||||
|
||||
* 2019/03/20
|
||||
* 支持编译Windows 32 位版本(感谢陈谭提供补丁)
|
||||
|
BIN
docs/manual/images/lcd_profile_t_0.png
Normal file
BIN
docs/manual/images/lcd_profile_t_0.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.0 KiB |
8
docs/manual/lcd_profile_t.md
Normal file
8
docs/manual/lcd_profile_t.md
Normal file
@ -0,0 +1,8 @@
|
||||
## lcd\_profile\_t
|
||||
### 概述
|
||||
![image](images/lcd_profile_t_0.png)
|
||||
|
||||
对现有LCD对象进行包装,实现对各个函数的时间统计,用于辅助定位性能瓶颈。
|
||||
|
||||
|
||||
----------------------------------
|
@ -20,7 +20,7 @@
|
||||
| <a href="#lcd_t_lcd_fill_rect">lcd\_fill\_rect</a> | 绘制实心矩形。 |
|
||||
| <a href="#lcd_t_lcd_get_clip_rect">lcd\_get\_clip\_rect</a> | 获取裁剪区域。 |
|
||||
| <a href="#lcd_t_lcd_get_desired_bitmap_format">lcd\_get\_desired\_bitmap\_format</a> | 获取期望的位图格式。绘制期望的位图格式可以提高绘制性能。 |
|
||||
| <a href="#lcd_t_lcd_get_point_color_t">lcd\_get\_point\_color\_t</a> | 获取指定点的颜色,对于基于非FrameBuffer的LCD,返回当前的fill_color。 |
|
||||
| <a href="#lcd_t_lcd_get_point_color">lcd\_get\_point\_color</a> | 获取指定点的颜色,对于基于非FrameBuffer的LCD,返回当前的fill_color。 |
|
||||
| <a href="#lcd_t_lcd_get_vgcanvas">lcd\_get\_vgcanvas</a> | 获取矢量图canvas。 |
|
||||
| <a href="#lcd_t_lcd_is_swappable">lcd\_is\_swappable</a> | 判读lcd是否支持swap。 |
|
||||
| <a href="#lcd_t_lcd_measure_text">lcd\_measure\_text</a> | 测量字符串占用的宽度。 |
|
||||
@ -63,7 +63,7 @@
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t lcd_begin_frame (lcd_t* lcd, rect_t* dirty_rect, bool_t anim_mode);
|
||||
ret_t lcd_begin_frame (lcd_t* lcd, rect_t* dirty_rect, lcd_draw_mode_t anim_mode);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
@ -73,7 +73,7 @@ ret_t lcd_begin_frame (lcd_t* lcd, rect_t* dirty_rect, bool_t anim_mode);
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| lcd | lcd\_t* | lcd对象。 |
|
||||
| dirty\_rect | rect\_t* | 需要绘制的区域。 |
|
||||
| anim\_mode | bool\_t | 动画模式,如果可能,直接画到显存而不是离线的framebuffer。 |
|
||||
| anim\_mode | lcd\_draw\_mode\_t | 动画模式,如果可能,直接画到显存而不是离线的framebuffer。 |
|
||||
#### lcd\_draw\_glyph 函数
|
||||
-----------------------
|
||||
|
||||
@ -111,7 +111,7 @@ ret_t lcd_draw_glyph (lcd_t* lcd, glyph_t* glyph, rect_t* src, xy_t x, xy_t y);
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t lcd_draw_hline (lcd_t* lcd, xy_t* x, xy_t* y, xy_t* w);
|
||||
ret_t lcd_draw_hline (lcd_t* lcd, xy_t x, xy_t y, xy_t w);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
@ -120,9 +120,9 @@ ret_t lcd_draw_hline (lcd_t* lcd, xy_t* x, xy_t* y, xy_t* w);
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| lcd | lcd\_t* | lcd对象。 |
|
||||
| x | xy\_t* | x坐标。 |
|
||||
| y | xy\_t* | y坐标。 |
|
||||
| w | xy\_t* | 直线宽度。 |
|
||||
| x | xy\_t | x坐标。 |
|
||||
| y | xy\_t | y坐标。 |
|
||||
| w | xy\_t | 直线宽度。 |
|
||||
#### lcd\_draw\_image 函数
|
||||
-----------------------
|
||||
|
||||
@ -229,7 +229,7 @@ ret_t lcd_draw_text (lcd_t* lcd, const wchar_t* str, uint32_t nr, xy_t x, xy_t y
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t lcd_draw_vline (lcd_t* lcd, xy_t* x, xy_t* y, xy_t* h);
|
||||
ret_t lcd_draw_vline (lcd_t* lcd, xy_t x, xy_t y, xy_t h);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
@ -238,9 +238,9 @@ ret_t lcd_draw_vline (lcd_t* lcd, xy_t* x, xy_t* y, xy_t* h);
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| lcd | lcd\_t* | lcd对象。 |
|
||||
| x | xy\_t* | x坐标。 |
|
||||
| y | xy\_t* | y坐标。 |
|
||||
| h | xy\_t* | 直线高度。 |
|
||||
| x | xy\_t | x坐标。 |
|
||||
| y | xy\_t | y坐标。 |
|
||||
| h | xy\_t | 直线高度。 |
|
||||
#### lcd\_end\_frame 函数
|
||||
-----------------------
|
||||
|
||||
@ -330,26 +330,26 @@ bitmap_format_t lcd_get_desired_bitmap_format (lcd_t* lcd);
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | bitmap\_format\_t | 返回期望的位图格式。 |
|
||||
| lcd | lcd\_t* | lcd对象。 |
|
||||
#### lcd\_get\_point\_color\_t 函数
|
||||
#### lcd\_get\_point\_color 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="lcd_t_lcd_get_point_color_t"> 获取指定点的颜色,对于基于非FrameBuffer的LCD,返回当前的fill_color。
|
||||
> <p id="lcd_t_lcd_get_point_color"> 获取指定点的颜色,对于基于非FrameBuffer的LCD,返回当前的fill_color。
|
||||
|
||||
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t lcd_get_point_color_t (lcd_t* lcd, xy_t x, xy_t y);
|
||||
color_t lcd_get_point_color (lcd_t* lcd, xy_t x, xy_t y);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| 返回值 | color\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| lcd | lcd\_t* | lcd对象。 |
|
||||
| x | xy\_t | x坐标。 |
|
||||
| y | xy\_t | y坐标。 |
|
||||
|
@ -51,6 +51,7 @@
|
||||
| -------- | ------------ |
|
||||
| <a href="#slider_t_slider_cast">slider\_cast</a> | 转换为slider对象(供脚本语言使用)。 |
|
||||
| <a href="#slider_t_slider_create">slider\_create</a> | 创建slider对象 |
|
||||
| <a href="#slider_t_slider_set_bar_size">slider\_set\_bar\_size</a> | 设置bar的宽度或高度。 |
|
||||
| <a href="#slider_t_slider_set_max">slider\_set\_max</a> | 设置滑块的最大值。 |
|
||||
| <a href="#slider_t_slider_set_min">slider\_set\_min</a> | 设置滑块的最小值。 |
|
||||
| <a href="#slider_t_slider_set_step">slider\_set\_step</a> | 设置滑块的拖动的最小单位。 |
|
||||
@ -61,6 +62,7 @@
|
||||
|
||||
| 属性名称 | 类型 | 说明 |
|
||||
| -------- | ----- | ------------ |
|
||||
| <a href="#slider_t_bar_size">bar\_size</a> | uint32\_t | bar的宽度或高度。 |
|
||||
| <a href="#slider_t_max">max</a> | uint16\_t | 最大值。 |
|
||||
| <a href="#slider_t_min">min</a> | uint16\_t | 最小值。 |
|
||||
| <a href="#slider_t_step">step</a> | uint16\_t | 拖动的最小单位。 |
|
||||
@ -120,6 +122,28 @@ widget_t* slider_create (widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
|
||||
| y | xy\_t | y坐标 |
|
||||
| w | wh\_t | 宽度 |
|
||||
| h | wh\_t | 高度 |
|
||||
#### slider\_set\_bar\_size 函数
|
||||
-----------------------
|
||||
|
||||
* 函数功能:
|
||||
|
||||
> <p id="slider_t_slider_set_bar_size"> 设置bar的宽度或高度。
|
||||
|
||||
|
||||
|
||||
* 函数原型:
|
||||
|
||||
```
|
||||
ret_t slider_set_bar_size (widget_t* widget, uint32_t bar_size);
|
||||
```
|
||||
|
||||
* 参数说明:
|
||||
|
||||
| 参数 | 类型 | 说明 |
|
||||
| -------- | ----- | --------- |
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| widget | widget\_t* | 控件对象。 |
|
||||
| bar\_size | uint32\_t | bar的宽度或高度。 |
|
||||
#### slider\_set\_max 函数
|
||||
-----------------------
|
||||
|
||||
@ -230,6 +254,23 @@ ret_t slider_set_vertical (widget_t* widget, bool_t vertical);
|
||||
| 返回值 | ret\_t | 返回RET\_OK表示成功,否则表示失败。 |
|
||||
| widget | widget\_t* | 控件对象。 |
|
||||
| vertical | bool\_t | 是否为垂直方向。 |
|
||||
#### bar\_size 属性
|
||||
-----------------------
|
||||
> <p id="slider_t_bar_size"> bar的宽度或高度。
|
||||
|
||||
|
||||
* 类型:uint32\_t
|
||||
|
||||
| 特性 | 是否支持 |
|
||||
| -------- | ----- |
|
||||
| 可直接读取 | 是 |
|
||||
| 可直接修改 | 否 |
|
||||
| 可持久化 | 是 |
|
||||
| 可脚本化 | 是 |
|
||||
| 可在IDE中设置 | 是 |
|
||||
| 可在XML中设置 | 是 |
|
||||
| 可通过widget\_get\_prop读取 | 是 |
|
||||
| 可通过widget\_set\_prop修改 | 是 |
|
||||
#### max 属性
|
||||
-----------------------
|
||||
> <p id="slider_t_max"> 最大值。
|
||||
|
@ -11,6 +11,7 @@
|
||||
| WIDGET\_PROP\_Y | Y坐标。 |
|
||||
| WIDGET\_PROP\_W | 宽度。 |
|
||||
| WIDGET\_PROP\_H | 高度。 |
|
||||
| WIDGET\_PROP\_BAR\_SIZE | slider中的bar的的宽度或高度。 |
|
||||
| WIDGET\_PROP\_OPACITY | 不透明度。 |
|
||||
| WIDGET\_PROP\_MIN\_W | 最小宽度。 |
|
||||
| WIDGET\_PROP\_MAX\_W | 最大宽度。 |
|
||||
@ -109,3 +110,4 @@
|
||||
| WIDGET\_PROP\_DELAY | 延迟时间(毫秒) |
|
||||
| WIDGET\_PROP\_IS\_KEYBOARD | 是否为键盘。 |
|
||||
| WIDGET\_PROP\_FOCUS | 设置为输入焦点。 |
|
||||
| WIDGET\_PROP\_FOCUSABLE | 是否支持焦点停留。 |
|
||||
|
@ -59,6 +59,12 @@ BEGIN_C_DECLS
|
||||
*/
|
||||
#define WIDGET_PROP_H "h"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_BAR_SIZE
|
||||
* slider中的bar的的宽度或高度。
|
||||
*/
|
||||
#define WIDGET_PROP_BAR_SIZE "bar_size"
|
||||
|
||||
/**
|
||||
* @const WIDGET_PROP_OPACITY
|
||||
* 不透明度。
|
||||
|
@ -71,6 +71,16 @@ static ret_t slider_paint_dragger(widget_t* widget, canvas_t* c) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static uint32_t slider_get_bar_size(widget_t* widget) {
|
||||
slider_t* slider = SLIDER(widget);
|
||||
|
||||
if (slider->vertical) {
|
||||
return slider->bar_size ? slider->bar_size : (widget->w >> 1);
|
||||
} else {
|
||||
return slider->bar_size ? slider->bar_size : (widget->h >> 1);
|
||||
}
|
||||
}
|
||||
|
||||
static ret_t slider_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
rect_t r;
|
||||
style_t* style = widget->astyle;
|
||||
@ -83,13 +93,13 @@ static ret_t slider_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
image_draw_type_t draw_type = slider->vertical ? IMAGE_DRAW_PATCH3_Y : IMAGE_DRAW_PATCH3_X;
|
||||
|
||||
if (slider->vertical) {
|
||||
r.x = widget->w >> 2;
|
||||
r.y = 0;
|
||||
r.w = widget->w >> 1;
|
||||
r.w = slider_get_bar_size(widget);
|
||||
r.x = (widget->w - r.w) / 2;
|
||||
r.h = widget->h - (widget->h * fvalue);
|
||||
} else {
|
||||
r.y = widget->h >> 2;
|
||||
r.h = widget->h >> 1;
|
||||
r.h = slider_get_bar_size(widget);
|
||||
r.y = (widget->h - r.h) / 2;
|
||||
r.w = widget->w - (widget->w * fvalue);
|
||||
r.x = widget->w - r.w;
|
||||
}
|
||||
@ -101,14 +111,14 @@ static ret_t slider_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
widget_fill_bg_rect(widget, c, &r, draw_type);
|
||||
|
||||
if (slider->vertical) {
|
||||
r.x = widget->w >> 2;
|
||||
r.w = widget->w >> 1;
|
||||
r.w = slider_get_bar_size(widget);
|
||||
r.x = (widget->w - r.w) / 2;
|
||||
r.h = (widget->h * fvalue);
|
||||
r.y = widget->h - r.h;
|
||||
} else {
|
||||
r.h = widget->h >> 1;
|
||||
r.h = slider_get_bar_size(widget);
|
||||
r.y = (widget->h - r.h) / 2;
|
||||
r.w = (widget->w * fvalue);
|
||||
r.y = widget->h >> 2;
|
||||
r.x = 0;
|
||||
}
|
||||
widget_fill_fg_rect(widget, c, &r, draw_type);
|
||||
@ -266,6 +276,15 @@ ret_t slider_set_step(widget_t* widget, uint16_t step) {
|
||||
return widget_invalidate(widget, NULL);
|
||||
}
|
||||
|
||||
ret_t slider_set_bar_size(widget_t* widget, uint32_t bar_size) {
|
||||
slider_t* slider = SLIDER(widget);
|
||||
return_value_if_fail(widget != NULL && bar_size > 0, RET_BAD_PARAMS);
|
||||
|
||||
slider->bar_size = bar_size;
|
||||
|
||||
return widget_invalidate(widget, NULL);
|
||||
}
|
||||
|
||||
ret_t slider_set_vertical(widget_t* widget, bool_t vertical) {
|
||||
slider_t* slider = SLIDER(widget);
|
||||
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
|
||||
@ -294,6 +313,9 @@ static ret_t slider_get_prop(widget_t* widget, const char* name, value_t* v) {
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_STEP)) {
|
||||
value_set_int(v, slider->step);
|
||||
return RET_OK;
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_BAR_SIZE)) {
|
||||
value_set_int(v, slider->bar_size);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
return RET_NOT_FOUND;
|
||||
@ -312,6 +334,8 @@ static ret_t slider_set_prop(widget_t* widget, const char* name, const value_t*
|
||||
return slider_set_max(widget, value_int(v));
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_STEP)) {
|
||||
return slider_set_step(widget, value_int(v));
|
||||
} else if (tk_str_eq(name, WIDGET_PROP_BAR_SIZE)) {
|
||||
return slider_set_bar_size(widget, value_int(v));
|
||||
}
|
||||
|
||||
return RET_NOT_FOUND;
|
||||
|
@ -108,6 +108,13 @@ typedef struct _slider_t {
|
||||
*/
|
||||
bool_t vertical;
|
||||
|
||||
/**
|
||||
* @property {uint32_t} bar_size
|
||||
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
|
||||
* bar的宽度或高度。
|
||||
*/
|
||||
uint32_t bar_size;
|
||||
|
||||
/*private*/
|
||||
bool_t dragging;
|
||||
} slider_t;
|
||||
@ -195,6 +202,17 @@ ret_t slider_set_max(widget_t* widget, uint16_t max);
|
||||
*/
|
||||
ret_t slider_set_step(widget_t* widget, uint16_t step);
|
||||
|
||||
/**
|
||||
* @method slider_set_bar_size
|
||||
* 设置bar的宽度或高度。
|
||||
* @annotation ["scriptable"]
|
||||
* @param {widget_t*} widget 控件对象。
|
||||
* @param {uint32_t} bar_size bar的宽度或高度。
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t slider_set_bar_size(widget_t* widget, uint32_t bar_size);
|
||||
|
||||
/**
|
||||
* @method slider_set_vertical
|
||||
* 设置滑块的方向。
|
||||
|
@ -31,6 +31,12 @@ TEST(slider, basic) {
|
||||
ASSERT_EQ(widget_get_prop(s, "step", &v2), RET_OK);
|
||||
ASSERT_EQ(value_int(&v1), value_int(&v2));
|
||||
|
||||
value_set_int(&v1, 10);
|
||||
ASSERT_EQ(widget_set_prop(s, "bar_size", &v1), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop(s, "bar_size", &v2), RET_OK);
|
||||
ASSERT_EQ(value_int(&v1), value_int(&v2));
|
||||
ASSERT_EQ(SLIDER(s)->bar_size, value_int(&v2));
|
||||
|
||||
value_set_bool(&v1, TRUE);
|
||||
ASSERT_EQ(widget_set_prop(s, "vertical", &v1), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop(s, "vertical", &v2), RET_OK);
|
||||
|
@ -9142,6 +9142,10 @@
|
||||
"desc": " 高度。\n\n",
|
||||
"name": "WIDGET_PROP_H"
|
||||
},
|
||||
{
|
||||
"desc": " slider中的bar的的宽度或高度。\n\n",
|
||||
"name": "WIDGET_PROP_BAR_SIZE"
|
||||
},
|
||||
{
|
||||
"desc": " 不透明度。\n\n",
|
||||
"name": "WIDGET_PROP_OPACITY"
|
||||
@ -27065,6 +27069,29 @@
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
"type": "widget_t*",
|
||||
"name": "widget",
|
||||
"desc": "控件对象。"
|
||||
},
|
||||
{
|
||||
"type": "uint32_t",
|
||||
"name": "bar_size",
|
||||
"desc": "bar的宽度或高度。"
|
||||
}
|
||||
],
|
||||
"annotation": {
|
||||
"scriptable": true
|
||||
},
|
||||
"desc": " 设置bar的宽度或高度。\r\n\r\n",
|
||||
"name": "slider_set_bar_size",
|
||||
"return": {
|
||||
"type": "ret_t",
|
||||
"desc": "返回RET_OK表示成功,否则表示失败。"
|
||||
}
|
||||
},
|
||||
{
|
||||
"params": [
|
||||
{
|
||||
@ -27171,6 +27198,19 @@
|
||||
"design": true,
|
||||
"scriptable": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "bar_size",
|
||||
"desc": " bar的宽度或高度。\r\n",
|
||||
"type": "uint32_t",
|
||||
"annotation": {
|
||||
"set_prop": true,
|
||||
"get_prop": true,
|
||||
"readable": true,
|
||||
"persitent": true,
|
||||
"design": true,
|
||||
"scriptable": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"header": "widgets/slider.h",
|
||||
|
Loading…
Reference in New Issue
Block a user