improve easing.h

This commit is contained in:
lixianjing 2023-03-14 18:01:45 +08:00
parent b0ac1aced2
commit 3cb6cb31bd
3 changed files with 29 additions and 13 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2023/03/14
* easing 完善注释与单元测试(感谢泽武提供补丁)
2023/03/13
* 完善编译脚本(感谢高源提供补丁)

View File

@ -22,11 +22,18 @@
#ifndef TK_EASING_H
#define TK_EASING_H
#include "tkc/types_def.h"
#include "tkc/darray.h"
#include "tkc/types_def.h"
BEGIN_C_DECLS
typedef float_t (*easing_func_t)(float_t k);
typedef struct _easing_name_func_t {
key_type_value_t* type_name_value;
easing_func_t easing_func;
} easing_name_func_t;
/**
* @enum easing_type_t
* @prefix EASING_
@ -157,17 +164,16 @@ typedef enum _easing_type_t {
EASING_FUNC_NR
} easing_type_t;
typedef float_t (*easing_func_t)(float_t k);
typedef struct _easing_name_func_t {
key_type_value_t* type_name_value;
easing_func_t easing_func;
} easing_name_func_t;
/**
* @class easing_t
* @annotation ["fake"]
*
*
*/
/**
* @method easing_get
*
* @annotation ["global"]
* @param {easing_type_t} type
*
* @return {easing_func_t}
@ -177,7 +183,6 @@ easing_func_t easing_get(easing_type_t type);
/**
* @method easing_register
*
* @annotation ["global"]
* @param {const char*} type_name
* @param {easing_func_t} easing_func
*

View File

@ -1,15 +1,23 @@
#include "tkc/easing.h"
#include "gtest/gtest.h"
#include "widgets/button.h"
#include "widget_animators/widget_animator_prop.h"
static float_t easing_linear(float_t k) {
return k;
}
TEST(easing, easingreg) {
TEST(easing, basic) {
ASSERT_EQ(easing_register("test1", easing_linear), EASING_FUNC_NR + 1);
ASSERT_EQ(easing_register("test2", easing_linear), EASING_FUNC_NR + 2);
ASSERT_EQ(easing_register("test3", easing_linear), EASING_FUNC_NR + 3);
ASSERT_EQ(easing_register("test4", easing_linear), EASING_FUNC_NR + 4);
ASSERT_EQ(easing_register("test5", easing_linear), EASING_FUNC_NR + 5);
uint32_t easing_type = easing_register("test3", easing_linear);
widget_t* button = button_create(NULL, 0, 0, 100, 30);
widget_animator_t* wa = widget_animator_prop_create(button, 1000, 0, (easing_type_t)easing_type, "x");
ASSERT_EQ(widget_animator_prop_set_params(wa, 0, 300), RET_OK);
widget_animator_destroy(wa);
widget_destroy(button);
}