improve get/set prop for state

This commit is contained in:
lixianjing 2024-02-19 11:09:33 +08:00
parent 25ac3f411e
commit c03494f84a
4 changed files with 14 additions and 2 deletions

View File

@ -2,6 +2,7 @@
2024/02/19
* 补充事件名(感谢兆坤提供补丁)
* 增加widget 通过 get_prop/set_prop函数设置state属性的功能。(感谢兆坤提供补丁)
2024/02/07
* 增加函数tk\_bits\_data\_to\_bytes\_data/tk\_bits\_data\_from\_bytes\_data

View File

@ -2145,6 +2145,9 @@ ret_t widget_set_prop(widget_t* widget, const char* name, const value_t* v) {
} else if (tk_str_eq(name, WIDGET_PROP_STYLE)) {
const char* name = value_str(v);
return widget_use_style(widget, name);
} else if (tk_str_eq(name, WIDGET_PROP_STATE)) {
const char* name = value_str(v);
return widget_set_state(widget, name);
} else if (tk_str_eq(name, WIDGET_PROP_ENABLE)) {
widget_set_enable(widget, value_bool(v));
} else if (tk_str_eq(name, WIDGET_PROP_FEEDBACK)) {
@ -2292,6 +2295,8 @@ ret_t widget_get_prop(widget_t* widget, const char* name, value_t* v) {
value_set_int(v, widget->dirty_rect_tolerance);
} else if (tk_str_eq(name, WIDGET_PROP_STYLE)) {
value_set_str(v, widget->style);
} else if (tk_str_eq(name, WIDGET_PROP_STATE)) {
value_set_str(v, widget->state);
} else if (tk_str_eq(name, WIDGET_PROP_ENABLE)) {
value_set_bool(v, widget->enable);
} else if (tk_str_eq(name, WIDGET_PROP_FEEDBACK)) {

View File

@ -453,7 +453,7 @@ struct _widget_t {
uint8_t destroying : 1;
/**
* @property {char*} state
* @annotation ["readable"]
* @annotation ["set_prop","get_prop","readable"]
* (widget_state_t)
*/
char* state;
@ -1557,7 +1557,7 @@ ret_t widget_set_focusable(widget_t* widget, bool_t focusable);
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} state (widget的整个生命周期有效)
* @param {const char*} state
*
* @return {ret_t} RET_OK表示成功
*/

View File

@ -353,6 +353,12 @@ BEGIN_C_DECLS
*/
#define WIDGET_PROP_STYLE "style"
/**
* @const WIDGET_PROP_STATE
*
*/
#define WIDGET_PROP_STATE "state"
/**
* @const WIDGET_PROP_ENABLE
*