improve comboxbox, allow user customize drop down button

This commit is contained in:
lixianjing 2019-11-06 15:47:40 +08:00
parent c52ebbbef6
commit 745fc7286f
6 changed files with 64 additions and 46 deletions

View File

@ -393,7 +393,7 @@
#include "assets/default/inc/images/visible.data"
#include "assets/default/inc/images/warn.data"
#include "assets/default/inc/images/zh.data"
#endif /*WITH_STB_IMAGE*/
#endif/*WITH_STB_IMAGE*/
#ifdef WITH_VGCANVAS
#include "assets/default/inc/images/ball.bsvg"
#include "assets/default/inc/images/china.bsvg"
@ -401,13 +401,13 @@
#include "assets/default/inc/images/pointer.bsvg"
#include "assets/default/inc/images/pointer_1.bsvg"
#include "assets/default/inc/images/pointer_4.bsvg"
#endif /*WITH_VGCANVAS*/
#endif/*WITH_VGCANVAS*/
#if defined(WITH_TRUETYPE_FONT)
#include "assets/default/inc/fonts/default.res"
#else /*WITH_TRUETYPE_FONT*/
#else/*WITH_TRUETYPE_FONT*/
#include "assets/default/inc/fonts/default.data"
#endif /*WITH_TRUETYPE_FONT*/
#endif /*WITH_FS_RES*/
#endif/*WITH_TRUETYPE_FONT*/
#endif/*WITH_FS_RES*/
ret_t assets_init(void) {
assets_manager_t* am = assets_manager();
@ -693,7 +693,7 @@ ret_t assets_init(void) {
assets_manager_add(am, image_pointer);
assets_manager_add(am, image_pointer_1);
assets_manager_add(am, image_pointer_4);
#endif /*WITH_VGCANVAS*/
#endif/*WITH_VGCANVAS*/
#endif
tk_init_assets();

View File

@ -1,5 +1,5 @@
TK_CONST_DATA_ALIGN(const unsigned char ui_combo_box[]) = {
0x04,0x00,0x01,0x01,0xdf,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,0x6f,
0x04,0x00,0x01,0x01,0x65,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,0x6f,
0x78,0x00,0x64,0x61,0x74,0x61,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
@ -10,44 +10,51 @@ TK_CONST_DATA_ALIGN(const unsigned char ui_combo_box[]) = {
0x00,0x00,0x1e,0x00,0x00,0x00,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x73,0x00,0x6c,0x65,0x66,0x74,0x3b,0x63,
0x65,0x6e,0x74,0x65,0x72,0x3b,0x72,0x69,0x67,0x68,0x74,0x3b,0x00,0x6c,0x65,0x66,0x74,0x5f,0x6d,0x61,
0x72,0x67,0x69,0x6e,0x00,0x36,0x00,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,
0x00,0x74,0x65,0x78,0x74,0x00,0x6c,0x65,0x66,0x74,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,
0x00,0x74,0x65,0x78,0x74,0x00,0x6c,0x65,0x66,0x74,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,0x14,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,0x72,0x69,0x67,0x68,0x74,0x3a,0x35,0x2c,0x79,0x3d,0x6d,0x69,0x64,0x64,0x6c,0x65,0x2c,0x77,
0x3d,0x32,0x30,0x2c,0x68,0x3d,0x32,0x30,0x29,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x63,0x6f,0x6d,0x62,
0x6f,0x62,0x6f,0x78,0x5f,0x64,0x6f,0x77,0x6e,0x00,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,
0x6f,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x1e,0x00,0x00,
0x00,0x6f,0x70,0x65,0x6e,0x5f,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x72,
0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x72,0x65,
0x64,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,0x6f,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x1e,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,0x35,0x2c,0x79,0x3d,0x62,0x6f,
0x74,0x74,0x6f,0x6d,0x3a,0x35,0x2c,0x77,0x3d,0x34,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6f,
0x70,0x74,0x69,0x6f,0x6e,0x73,0x00,0x31,0x3a,0x6f,0x6b,0x3b,0x32,0x3a,0x63,0x61,0x6e,0x63,0x65,0x6c,
0x3b,0x00,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x72,0x5f,0x74,
0x65,0x78,0x74,0x00,0x6f,0x6b,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,0x6f,0x78,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x1e,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,0x35,
0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x35,0x30,0x2c,0x77,0x3d,0x34,0x35,0x25,0x2c,0x68,
0x3d,0x33,0x30,0x29,0x00,0x6f,0x70,0x65,0x6e,0x5f,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x6c,0x61,0x6e,
0x67,0x75,0x61,0x67,0x65,0x00,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,
0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x65,0x6e,0x67,0x6c,0x69,0x73,0x68,0x00,0x00,0x00,0x63,0x6f,
0x00,0x6c,0x65,0x66,0x74,0x5f,0x6d,0x61,0x72,0x67,0x69,0x6e,0x00,0x36,0x00,0x6f,0x70,0x65,0x6e,0x5f,
0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x63,0x6f,0x6c,0x6f,0x72,0x00,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,
0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x72,0x65,0x64,0x00,0x00,0x00,0x63,0x6f,
0x6d,0x62,0x6f,0x5f,0x62,0x6f,0x78,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,0x2d,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2d,0x00,
0x00,0x00,0x1e,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,0x72,0x69,0x67,0x68,0x74,0x3a,0x35,0x2c,0x79,0x3d,0x62,0x6f,
0x74,0x74,0x6f,0x6d,0x3a,0x35,0x2c,0x77,0x3d,0x34,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6f,
0x70,0x74,0x69,0x6f,0x6e,0x73,0x00,0x31,0x3a,0x6f,0x6b,0x3b,0x32,0x3a,0x63,0x61,0x6e,0x63,0x65,0x6c,
0x3b,0x00,0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x65,0x78,0x74,
0x00,0x6f,0x6b,0x00,0x6c,0x6f,0x63,0x61,0x6c,0x69,0x7a,0x65,0x5f,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x73,
0x00,0x66,0x61,0x6c,0x73,0x65,0x00,0x00,0x00,0x6c,0x61,0x62,0x65,0x6c,0x00,0x00,0x00,0x00,0x00,0x00,
0x66,0x61,0x75,0x6c,0x74,0x28,0x78,0x3d,0x35,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x35,
0x2c,0x77,0x3d,0x34,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x73,
0x00,0x31,0x3a,0x6f,0x6b,0x3b,0x32,0x3a,0x63,0x61,0x6e,0x63,0x65,0x6c,0x3b,0x00,0x72,0x65,0x61,0x64,
0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x72,0x5f,0x74,0x65,0x78,0x74,0x00,0x6f,0x6b,
0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,0x6f,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x2d,0x00,0x00,0x00,0x1e,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,0x35,0x2c,0x79,0x3d,0x62,0x6f,0x74,
0x74,0x6f,0x6d,0x3a,0x35,0x30,0x2c,0x77,0x3d,0x34,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6f,
0x70,0x65,0x6e,0x5f,0x77,0x69,0x6e,0x64,0x6f,0x77,0x00,0x6c,0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x00,
0x72,0x65,0x61,0x64,0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x72,0x5f,0x74,0x65,0x78,
0x74,0x00,0x65,0x6e,0x67,0x6c,0x69,0x73,0x68,0x00,0x00,0x00,0x63,0x6f,0x6d,0x62,0x6f,0x5f,0x62,0x6f,
0x78,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,0x2d,0x00,0x00,0x00,0x1e,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,0x72,0x69,0x67,0x68,0x74,0x3a,0x35,0x2c,0x79,0x3d,0x62,0x6f,0x74,0x74,0x6f,0x6d,0x3a,0x35,
0x2c,0x77,0x3d,0x34,0x35,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x73,
0x00,0x31,0x3a,0x6f,0x6b,0x3b,0x32,0x3a,0x63,0x61,0x6e,0x63,0x65,0x6c,0x3b,0x00,0x72,0x65,0x61,0x64,
0x6f,0x6e,0x6c,0x79,0x00,0x74,0x72,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x6f,0x6b,0x00,0x6c,0x6f,
0x63,0x61,0x6c,0x69,0x7a,0x65,0x5f,0x6f,0x70,0x74,0x69,0x6f,0x6e,0x73,0x00,0x66,0x61,0x6c,0x73,0x65,
0x00,0x00,0x00,0x6c,0x61,0x62,0x65,0x6c,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,0x32,0x00,0x00,0x00,0x1e,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,
0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x6d,0x69,0x64,0x64,0x6c,0x65,0x3a,0x2d,0x32,0x30,0x2c,0x77,
0x3d,0x35,0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6f,0x6c,0x64,0x5f,
0x76,0x61,0x6c,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x6c,0x61,0x62,0x65,0x6c,0x00,
0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x1e,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,0x65,0x6e,0x74,0x65,0x72,0x2c,
0x79,0x3d,0x6d,0x69,0x64,0x64,0x6c,0x65,0x3a,0x2d,0x32,0x30,0x2c,0x77,0x3d,0x35,0x30,0x25,0x2c,0x68,
0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x6f,0x6c,0x64,0x5f,0x76,0x61,0x6c,0x75,0x65,0x00,
0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x6c,0x61,0x62,0x65,0x6c,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,0x32,0x00,0x00,0x00,0x1e,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,0x65,0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x6d,0x69,0x64,0x64,0x6c,0x65,0x3a,
0x32,0x30,0x2c,0x77,0x3d,0x35,0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,
0x76,0x61,0x6c,0x75,0x65,0x00,0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*1039*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,0x00,0x1e,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,0x65,
0x6e,0x74,0x65,0x72,0x2c,0x79,0x3d,0x6d,0x69,0x64,0x64,0x6c,0x65,0x3a,0x32,0x30,0x2c,0x77,0x3d,0x35,
0x30,0x25,0x2c,0x68,0x3d,0x33,0x30,0x29,0x00,0x6e,0x61,0x6d,0x65,0x00,0x76,0x61,0x6c,0x75,0x65,0x00,
0x74,0x65,0x78,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};/*1173*/

View File

@ -1,6 +1,8 @@
<window anim_hint="htranslate">
<combo_box left_margin="6" readonly="true" x="10" y="5" w="200" h="30" text="left" options="left;center;right;"/>
<combo_box open_window="color" readonly="true" x="10" y="50" w="200" h="30" text="red"/>
<combo_box left_margin="6" readonly="true" x="10" y="5" w="200" h="30" text="left" options="left;center;right;">
<button style="combobox_down" x="right:5" y="middle" w="20" h="20"/>
</combo_box>
<combo_box left_margin="6" open_window="color" readonly="true" x="10" y="50" w="200" h="30" text="red"/>
<combo_box readonly="true" x="5" y="bottom:5" w="45%" h="30" tr_text="ok" options="1:ok;2:cancel;"/>
<combo_box open_window="language" readonly="true" x="5" y="bottom:50" w="45%" h="30" tr_text="english"/>

View File

@ -4,6 +4,7 @@
* 修改emitter中的错误感谢朝泽提供补丁
* 修改image manager 对raw image的处理增加graphic buffer之后raw image也需要由image manager管理。
* 增加scripts/release.sh脚本用于将运行时需要的文件拷贝到release目录。
* 允许在XML文件中指定combobox按钮的位置大小和样式。
* 2019/11/05
* list\_view/list\_view\_h 增加pageup/pagedown按键处理。

View File

@ -157,7 +157,11 @@ static ret_t combo_box_set_prop(widget_t* widget, const char* name, const value_
static ret_t combo_box_on_layout_children(widget_t* widget) {
widget_t* button = widget_lookup_by_type(widget, "button", TRUE);
widget_move_resize(button, widget->w - widget->h, 0, widget->h, widget->h);
if (button->auto_created) {
widget_move_resize(button, widget->w - widget->h, 0, widget->h, widget->h);
} else {
widget_layout(button);
}
return RET_OK;
}
@ -200,6 +204,11 @@ static ret_t combo_box_on_event(widget_t* widget, event_t* e) {
}
static ret_t combo_box_on_add_child(widget_t* widget, widget_t* child) {
widget_t* button = widget_lookup_by_type(widget, "button", TRUE);
if (button != NULL && button != child) {
widget_destroy(button);
}
widget_on(child, EVT_CLICK, combo_box_on_button_click, widget);
return RET_FAIL;
@ -359,7 +368,6 @@ widget_t* combo_box_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
popup = button_create(widget, 0, 0, 0, 0);
popup->auto_created = TRUE;
combo_box_set_item_height(widget, 30);
widget_set_name(popup, "popup");
widget_use_style(popup, "combobox_down");
return widget;