Skip to content

Commit

Permalink
improve vtable
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Dec 21, 2023
1 parent 05c9d0f commit 267cb72
Show file tree
Hide file tree
Showing 20 changed files with 2,696 additions and 215 deletions.
3 changes: 3 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# 最新动态

2023/12/21
* 增加控件继承的函数指针查找父集的逻辑(感谢智明提供补丁)

2023/12/19
* 修复API注释(感谢俊杰提供补丁)
* 修复关闭没有动画的高亮对话框后立刻再关闭一个有动画的窗口的崩溃问题(感谢智明提供补丁)
Expand Down
8 changes: 5 additions & 3 deletions src/base/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "tkc/utils.h"
#include "base/widget.h"
#include "base/layout.h"
#include "base/widget_vtable.h"
#include "base/self_layouter_factory.h"
#include "base/children_layouter_factory.h"

Expand Down Expand Up @@ -114,13 +115,14 @@ ret_t widget_layout_children_default(widget_t* widget) {
}

ret_t widget_layout_children(widget_t* widget) {
ret_t ret = RET_OK;
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);

if (widget->vt->on_layout_children != NULL) {
return widget->vt->on_layout_children(widget);
} else {
ret = widget_vtable_on_layout_children(widget);
if (ret == RET_NOT_IMPL) {
return widget_layout_children_default(widget);
}
return ret;
}

ret_t widget_set_self_layout(widget_t* widget, const char* params) {
Expand Down
5 changes: 3 additions & 2 deletions src/base/self_layouter.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "base/widget.h"
#include "base/widget_vtable.h"
#include "base/self_layouter.h"

const char* self_layouter_to_string(self_layouter_t* layouter) {
Expand All @@ -34,8 +35,8 @@ const char* self_layouter_to_string(self_layouter_t* layouter) {

ret_t self_layouter_layout(self_layouter_t* layouter, widget_t* widget, rect_t* area) {
if (layouter == NULL) {
if (widget->auto_adjust_size && widget->vt->auto_adjust_size != NULL) {
widget->vt->auto_adjust_size(widget);
if (widget->auto_adjust_size) {
widget_vtable_auto_adjust_size(widget);
}

return RET_FAIL;
Expand Down
Loading

0 comments on commit 267cb72

Please sign in to comment.