mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
add assets_manager_get_theme_name
This commit is contained in:
parent
d82004406e
commit
512b3845bc
@ -7,6 +7,7 @@
|
||||
* 支持image\_set\_image 检查是否相同的图片(感谢智明提供补丁)
|
||||
* 支持 mutable\_image动态绑定贴图属性(感谢智明提供补丁)
|
||||
* 支持widget\_set\_text支持字符串比较相同字符串不刷新和新增widget\_set\_text\_ex函数支持不检查以及测试用例(感谢智明提供补丁)
|
||||
* 支持获取当前资源管理的主题名称(感谢智明提供补丁)
|
||||
|
||||
2022/08/30
|
||||
* 完善注释(感谢雨欣提供补丁)
|
||||
|
@ -608,6 +608,11 @@ ret_t assets_manager_clear_all(assets_manager_t* am) {
|
||||
return darray_clear(&(am->assets));
|
||||
}
|
||||
|
||||
const char* assets_manager_get_theme_name(assets_manager_t* am) {
|
||||
return_value_if_fail(am != NULL, NULL);
|
||||
return am->theme;
|
||||
}
|
||||
|
||||
ret_t assets_manager_set_theme(assets_manager_t* am, const char* theme) {
|
||||
return_value_if_fail(am != NULL, RET_BAD_PARAMS);
|
||||
|
||||
|
@ -479,6 +479,16 @@ ret_t assets_managers_set_theme(const char* theme);
|
||||
*/
|
||||
ret_t assets_managers_unref(assets_manager_t* am);
|
||||
|
||||
/**
|
||||
* @method assets_manager_get_theme_name
|
||||
* 获取当前的主题名称。
|
||||
* @annotation ["deconstructor"]
|
||||
* @param {assets_manager_t*} am 资源管理器对象。
|
||||
*
|
||||
* @return {const char*} 返回主题名称。
|
||||
*/
|
||||
const char* assets_manager_get_theme_name(assets_manager_t* am);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_ASSETS_MANAGER_H*/
|
||||
|
@ -666,7 +666,7 @@ const char* widget_get_theme_name(widget_t* widget) {
|
||||
assets_manager_t* am = widget_get_assets_manager(widget);
|
||||
return_value_if_fail(am != NULL, NULL);
|
||||
|
||||
return am->name;
|
||||
return assets_manager_get_theme_name(am);
|
||||
}
|
||||
|
||||
ret_t widget_set_theme(widget_t* widget, const char* name) {
|
||||
|
@ -48,6 +48,12 @@ TEST(AssetsManager, basic) {
|
||||
ASSERT_EQ(assets_manager_ref_ex(rm, ASSET_TYPE_FONT, ASSET_TYPE_FONT_TTF, "font1"), &font1);
|
||||
ASSERT_EQ(assets_manager_ref_ex(rm, ASSET_TYPE_FONT, ASSET_TYPE_FONT_BMP, "font1"), &font2);
|
||||
|
||||
ASSERT_EQ(assets_manager_set_theme(rm, "dark"), RET_OK);
|
||||
ASSERT_STREQ(assets_manager_get_theme_name(rm), "dark");
|
||||
|
||||
ASSERT_EQ(assets_manager_set_theme(rm, "default"), RET_OK);
|
||||
ASSERT_STREQ(assets_manager_get_theme_name(rm), "default");
|
||||
|
||||
assets_manager_destroy(rm);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user