add progress event

This commit is contained in:
lixianjing 2019-11-26 11:32:37 +08:00
parent e26f80408f
commit ed94230c0c
2 changed files with 51 additions and 6 deletions

View File

@ -70,3 +70,25 @@ progress_event_t* progress_event_cast(event_t* event) {
return (progress_event_t*)event;
}
event_t* prop_change_event_init(prop_change_event_t* event, uint32_t type, const char* name,
const value_t* value) {
return_value_if_fail(event != NULL, NULL);
memset(event, 0x00, sizeof(*event));
event->e.type = type;
event->name = name;
event->value = value;
return (event_t*)(event);
}
event_t* progress_event_init(progress_event_t* event, uint32_t percent) {
return_value_if_fail(event != NULL, NULL);
memset(event, 0x00, sizeof(*event));
event->e.type = EVT_PROGRESS;
event->percent = percent;
return (event_t*)(event);
}

View File

@ -65,7 +65,7 @@ typedef enum _event_base_type_t {
EVT_PROPS_CHANGED,
/**
* @const EVT_PROGRESS
* Progress changed(progress_event_t)
* (progress_event_t)
*/
EVT_PROGRESS,
/**
@ -182,24 +182,36 @@ typedef struct _prop_change_event_t {
* event对象转prop_change_event_t对象使
* @param {event_t*} event event对象
*
* @return {prop_change_event_t*}
* @return {prop_change_event_t*} event对
*/
prop_change_event_t* prop_change_event_cast(event_t* event);
/**
* @method prop_change_event_init
* prop change event
*
* @param {prop_change_event_t*} event event对象
* @param {uint32_t} percent
*
* @return {event_t*} event对象
*/
event_t* prop_change_event_init(prop_change_event_t* event, uint32_t type, const char* name,
const value_t* value);
/**
* @class progress_event_t
* @annotation ["scriptable"]
* @parent event_t
*
*
*/
typedef struct _progress_event_t {
event_t e;
/**
* @property {const char*} percent
* @annotation ["readable", "scriptable"]
* percent
*
*/
uint32_t percent;
uint32_t percent;
} progress_event_t;
/**
@ -208,10 +220,21 @@ typedef struct _progress_event_t {
* event对象转progress_event_t对象使
* @param {event_t*} event event对象
*
* @return {progress_event_t*}
* @return {progress_event_t*} event对
*/
progress_event_t* progress_event_cast(event_t* event);
/**
* @method progress_event_init
* progress event
*
* @param {progress_event_t*} event event对象
* @param {uint32_t} percent
*
* @return {event_t*} event对象
*/
event_t* progress_event_init(progress_event_t* event, uint32_t percent);
END_C_DECLS
#endif /**TK_EVENT_H*/