mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 10:38:47 +08:00
add tab_button_group_remove_index
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
This commit is contained in:
parent
c34395b47b
commit
82bfbfc160
@ -639,6 +639,19 @@ static ret_t on_clone_view(void* ctx, event_t* e) {
|
|||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ret_t on_remove_tab_by_index(void* ctx, event_t* e) {
|
||||||
|
char buff[MAX_PATH] = {0};
|
||||||
|
widget_t* iter = WIDGET(e->target);
|
||||||
|
widget_t* win = widget_get_window(iter);
|
||||||
|
widget_t* edit = widget_lookup(win, "remove_tab_index", TRUE);
|
||||||
|
widget_t* tab_button_group = widget_lookup_by_type(win, WIDGET_TYPE_TAB_BUTTON_GROUP, FALSE);
|
||||||
|
|
||||||
|
if (edit != NULL && widget_get_text_utf8(edit, buff, sizeof(buff)) == RET_OK) {
|
||||||
|
return tab_button_group_remove_index(tab_button_group, tk_atoi(buff));
|
||||||
|
}
|
||||||
|
return RET_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
static ret_t on_remove_tab_idle(const idle_info_t* idle) {
|
static ret_t on_remove_tab_idle(const idle_info_t* idle) {
|
||||||
widget_t* iter = WIDGET(idle->ctx);
|
widget_t* iter = WIDGET(idle->ctx);
|
||||||
int32_t remove_index = widget_index_of(iter);
|
int32_t remove_index = widget_index_of(iter);
|
||||||
@ -1134,7 +1147,10 @@ static ret_t install_one(void* ctx, const void* iter) {
|
|||||||
} else {
|
} else {
|
||||||
widget_on(widget, EVT_CLICK, on_remove_tab, widget);
|
widget_on(widget, EVT_CLICK, on_remove_tab, widget);
|
||||||
}
|
}
|
||||||
} else if (tk_str_eq(name, "remove_self")) {
|
} else if (tk_str_eq(name, "remove_tab_by_index")) {
|
||||||
|
widget_on(widget, EVT_CLICK, on_remove_tab_by_index, widget);
|
||||||
|
}
|
||||||
|
else if (tk_str_eq(name, "remove_self")) {
|
||||||
widget_on(widget, EVT_CLICK, on_remove_self, widget);
|
widget_on(widget, EVT_CLICK, on_remove_self, widget);
|
||||||
} else if (tk_str_eq(name, "remove_view")) {
|
} else if (tk_str_eq(name, "remove_view")) {
|
||||||
widget_on(widget, EVT_CLICK, on_remove_view, widget);
|
widget_on(widget, EVT_CLICK, on_remove_view, widget);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<button name="remove_tab" x="r" y="m" w="20" h="20" tr_text="x"/>
|
<button name="remove_tab" x="r" y="m" w="20" h="20" tr_text="x"/>
|
||||||
</tab_button>
|
</tab_button>
|
||||||
</tab_button_group>
|
</tab_button_group>
|
||||||
<pages x="c" y="42" w="90%" h="-60" value="1">
|
<pages x="c" y="42" w="90%" h="350" value="1">
|
||||||
<view name="clone_view" w="100%" h="100%">
|
<view name="clone_view" w="100%" h="100%">
|
||||||
<label x="c" y="m" w="100%" h="60" text="0"/>
|
<label x="c" y="m" w="100%" h="60" text="0"/>
|
||||||
<button name="clone_tab" x="c" y="bottom:100" w="80" h="40" tr_text="Clone" />
|
<button name="clone_tab" x="c" y="bottom:100" w="80" h="40" tr_text="Clone" />
|
||||||
@ -24,4 +24,8 @@
|
|||||||
<button name="clone_tab" x="c" y="bottom:100" w="80" h="40" tr_text="Clone" />
|
<button name="clone_tab" x="c" y="bottom:100" w="80" h="40" tr_text="Clone" />
|
||||||
</view>
|
</view>
|
||||||
</pages>
|
</pages>
|
||||||
|
<view x="c" y="400" w="90%" h="40">
|
||||||
|
<edit name="remove_tab_index" x="0" y="0" w="80" h="40" input_type="uint" step="1" text="0" />
|
||||||
|
<button name="remove_tab_by_index" x="100" y="0" w="80" h="40" tr_text="Remove" />
|
||||||
|
</view>
|
||||||
</window>
|
</window>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# 最新动态
|
# 最新动态
|
||||||
|
|
||||||
|
2024/11/26
|
||||||
|
* 增加tab_button_group删除tab_button和对应page的函数(感谢智明提供补丁)
|
||||||
|
|
||||||
2024/11/22
|
2024/11/22
|
||||||
* 修复 mledit编译警告(感谢泽武提供补丁)
|
* 修复 mledit编译警告(感谢泽武提供补丁)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
TK_CONST_DATA_ALIGN(const unsigned char ui_tab_remove_default[]) = {
|
TK_CONST_DATA_ALIGN(const unsigned char ui_tab_remove_default[]) = {
|
||||||
0x04,0x00,0x01,0x01,0x7c,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x61,0x62,0x5f,0x72,0x65,0x6d,0x6f,
|
0x04,0x00,0x01,0x01,0x98,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x74,0x61,0x62,0x5f,0x72,0x65,0x6d,0x6f,
|
||||||
0x76,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x76,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x12,0x12,0x22,0x11,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
@ -45,9 +45,9 @@ TK_CONST_DATA_ALIGN(const unsigned char ui_tab_remove_default[]) = {
|
|||||||
0x76,0x65,0x5f,0x74,0x61,0x62,0x00,0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x78,0x00,0x00,0x00,0x00,
|
0x76,0x65,0x5f,0x74,0x61,0x62,0x00,0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x78,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x70,0x61,0x67,0x65,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x70,0x61,0x67,0x65,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2a,0x00,0x00,
|
||||||
0x00,0x5a,0x00,0x00,0x00,0xc4,0xff,0xff,0xff,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
0x00,0x5a,0x00,0x00,0x00,0x5e,0x01,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,
|
||||||
0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x34,0x32,0x2c,0x77,0x3d,
|
0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x34,0x32,0x2c,0x77,0x3d,
|
||||||
0x39,0x30,0x25,0x2c,0x68,0x3d,0x2d,0x36,0x30,0x29,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x31,0x00,0x00,
|
0x39,0x30,0x25,0x2c,0x68,0x3d,0x33,0x35,0x30,0x29,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,0x31,0x00,0x00,
|
||||||
0x76,0x69,0x65,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x76,0x69,0x65,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
0x64,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,
|
0x64,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,
|
||||||
@ -96,5 +96,19 @@ TK_CONST_DATA_ALIGN(const unsigned char ui_tab_remove_default[]) = {
|
|||||||
0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,
|
0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,
|
||||||
0x63,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x31,0x30,0x30,0x2c,0x77,0x3d,0x38,0x30,0x2c,
|
0x63,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x31,0x30,0x30,0x2c,0x77,0x3d,0x38,0x30,0x2c,
|
||||||
0x68,0x3d,0x34,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x6c,0x6f,0x6e,0x65,0x5f,0x74,0x61,0x62,
|
0x68,0x3d,0x34,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x63,0x6c,0x6f,0x6e,0x65,0x5f,0x74,0x61,0x62,
|
||||||
0x00,0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x6e,0x65,0x00,0x00,0x00,0x00,0x00,0x00,
|
0x00,0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x43,0x6c,0x6f,0x6e,0x65,0x00,0x00,0x00,0x00,0x00,0x76,
|
||||||
0x00,0x00,0x00,0x00,};/*1964*/
|
0x69,0x65,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x01,0x00,0x00,0x5a,
|
||||||
|
0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x73,0x65,0x6c,0x66,0x5f,0x6c,0x61,0x79,0x6f,0x75,0x74,0x00,0x64,
|
||||||
|
0x65,0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x63,0x2c,0x79,0x3d,0x34,0x30,0x30,0x2c,0x77,0x3d,0x39,
|
||||||
|
0x30,0x25,0x2c,0x68,0x3d,0x34,0x30,0x29,0x00,0x00,0x65,0x64,0x69,0x74,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x69,0x6e,
|
||||||
|
0x70,0x75,0x74,0x5f,0x74,0x79,0x70,0x65,0x00,0x75,0x69,0x6e,0x74,0x00,0x6e,0x61,0x6d,0x65,0x00,0x72,
|
||||||
|
0x65,0x6d,0x6f,0x76,0x65,0x5f,0x74,0x61,0x62,0x5f,0x69,0x6e,0x64,0x65,0x78,0x00,0x73,0x74,0x65,0x70,
|
||||||
|
0x00,0x31,0x00,0x74,0x65,0x78,0x74,0x00,0x30,0x00,0x00,0x00,0x62,0x75,0x74,0x74,0x6f,0x6e,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x00,0x00,0x28,0x00,0x00,0x00,
|
||||||
|
0x6e,0x61,0x6d,0x65,0x00,0x72,0x65,0x6d,0x6f,0x76,0x65,0x5f,0x74,0x61,0x62,0x5f,0x62,0x79,0x5f,0x69,
|
||||||
|
0x6e,0x64,0x65,0x78,0x00,0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x52,0x65,0x6d,0x6f,0x76,0x65,0x00,
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*2248*/
|
||||||
|
Binary file not shown.
@ -425,6 +425,18 @@ ret_t tab_button_group_set_drag_child(widget_t* widget, bool_t drag_child) {
|
|||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret_t tab_button_group_remove_index(widget_t* widget, uint32_t index) {
|
||||||
|
widget_t* pages = NULL;
|
||||||
|
tab_button_group_t* tab_button_group = TAB_BUTTON_GROUP(widget);
|
||||||
|
return_value_if_fail(tab_button_group != NULL && index < widget_count_children(widget), RET_BAD_PARAMS);
|
||||||
|
|
||||||
|
pages = widget_lookup_by_type(widget->parent, WIDGET_TYPE_PAGES, TRUE);
|
||||||
|
|
||||||
|
widget_destroy(widget_get_child(pages, index));
|
||||||
|
widget_destroy(widget_get_child(widget, index));
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static ret_t tab_button_group_on_destroy(widget_t* widget) {
|
static ret_t tab_button_group_on_destroy(widget_t* widget) {
|
||||||
tab_button_group_t* tab_button_group = TAB_BUTTON_GROUP(widget);
|
tab_button_group_t* tab_button_group = TAB_BUTTON_GROUP(widget);
|
||||||
|
@ -160,6 +160,17 @@ ret_t tab_button_group_set_scrollable(widget_t* widget, bool_t scrollable);
|
|||||||
*/
|
*/
|
||||||
ret_t tab_button_group_set_drag_child(widget_t* widget, bool_t drag_child);
|
ret_t tab_button_group_set_drag_child(widget_t* widget, bool_t drag_child);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method tab_button_group_remove_index
|
||||||
|
* 设置删除 tab_button_group 控件中的 tab_button 控件和对应页。
|
||||||
|
* @annotation ["scriptable"]
|
||||||
|
* @param {widget_t*} widget 控件对象。
|
||||||
|
* @param {uint32_t} index tab_button 的序号。
|
||||||
|
*
|
||||||
|
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||||
|
*/
|
||||||
|
ret_t tab_button_group_remove_index(widget_t* widget, uint32_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method tab_button_group_cast
|
* @method tab_button_group_cast
|
||||||
* 转换tab_button_group对象(供脚本语言使用)。
|
* 转换tab_button_group对象(供脚本语言使用)。
|
||||||
|
Loading…
Reference in New Issue
Block a user