refactoring

This commit is contained in:
lixianjing 2018-03-30 22:15:45 +08:00
parent cc2f8c4986
commit c73358008b
26 changed files with 211 additions and 1740 deletions

View File

@ -87,21 +87,22 @@ ret_t application_init() {
show_dialog = button_create(win, 190, 5, 80, 30);
widget_set_text(show_dialog, L"Dialog");
widget_use_style(show_dialog, "1:blue_img");
image = image_create(win, 10, 230, 100, 100);
image_set_image_name(image, "earth");
label = label_create(win, 10, 40, 80, 30);
widget_set_text(label, L"Left");
label_set_text_align_h(label, ALIGN_H_LEFT);
widget_use_style(label, "3:left");
label = label_create(win, 100, 40, 80, 30);
widget_set_text(label, L"Center");
label_set_text_align_h(label, ALIGN_H_CENTER);
widget_use_style(label, "4:center");
label = label_create(win, 200, 40, 80, 30);
widget_set_text(label, L"Right");
label_set_text_align_h(label, ALIGN_H_RIGHT);
widget_use_style(label, "5:right");
progress_bar = progress_bar_create(win, 10, 80, 168, 30);
widget_set_value(progress_bar, 40);

View File

@ -4,7 +4,7 @@
<button state="pressed" bg-color="#c0c0c0" text-color="black" border-color="#a0a0a0" />
<button state="over" bg-color="#e0e0e0" text-color="black" border-color="#a0a0a0" />
<button state="disable" bg-color="gray" text-color="#d0d0d0" border-color="#a0a0a0" />
<label state="normal" bg-color="#f0f0f0" text-color="black" border-color="#a0a0a0" />
<label state="normal" text-color="black" />
<progress_bar state="normal" bg-color="#f0f0f0" text-color="gold" fg-color="black" border-color="#a0a0a0" />
<check_button state="checked" bg-color="#f0f0f0" text-color="black" icon="checked" />
<check_button state="unchecked" bg-color="#f0f0f0" text-color="black" icon="unchecked" />
@ -12,7 +12,12 @@
<radio_button state="unchecked" bg-color="#f0f0f0" text-color="black" icon="radio_unchecked" />
<window style-type="1:bricks" bg-image="bricks" bg-image-draw-type="repeat"/>
<label style-type="1:green" bg-color="#f0f0f0" text-color="green" border-color="#a0a0a0" />
<label style-type="1:green" text-color="green" />
<label style-type="3:left" text-color="red" text-align-h="left" border-color="#a0a0a0" margin="4" />
<label style-type="4:center" text-color="green" text-align-h="center" border-color="#a0a0a0" />
<label style-type="5:right" text-color="blue" text-align-h="right" border-color="#a0a0a0" margin="4"/>
<image style-type="1:border" border-color="#000000" bg-color="#e0e0e0"/>
<button style-type="1:blue_img" state="normal" bg-image="btn_blue_n" bg-image-draw-type="3patch_x" text-color="white"/>
<button style-type="1:blue_img" state="pressed" bg-image="btn_blue_p" bg-image-draw-type="3patch_x" text-color="white"/>

View File

@ -116,4 +116,4 @@ const unsigned char image_radio_unchecked[] = {
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,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,};
0xff,0x7f,0x00,0x00,};

View File

@ -1,44 +1,49 @@
const unsigned char theme_default[] = {
0x03,0x00,0x00,0x00,0x2e,0x03,0x00,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x00,0x64,0x61,0x74,0x61,
0x00,0x00,0x00,0x00,0xfd,0xfc,0xfb,0xfa,0x00,0x00,0x00,0x00,0x12,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0x9c,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0xc5,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0xfe,0x00,0x00,0x00,
0x02,0x00,0x0a,0x00,0x1e,0x01,0x00,0x00,0x03,0x00,0x0a,0x00,0x3e,0x01,0x00,0x00,0x04,0x00,0x0a,0x00,
0x5e,0x01,0x00,0x00,0x01,0x00,0x09,0x00,0x7e,0x01,0x00,0x00,0x01,0x00,0x0d,0x00,0x9e,0x01,0x00,0x00,
0x06,0x00,0x0f,0x00,0xc6,0x01,0x00,0x00,0x07,0x00,0x0f,0x00,0xea,0x01,0x00,0x00,0x06,0x00,0x10,0x00,
0x10,0x02,0x00,0x00,0x07,0x00,0x10,0x00,0x3a,0x02,0x00,0x00,0x01,0x01,0x02,0x00,0x66,0x02,0x00,0x00,
0x01,0x01,0x09,0x00,0x81,0x02,0x00,0x00,0x01,0x01,0x0b,0x00,0xa1,0x02,0x00,0x00,0x01,0x01,0x0a,0x00,
0xb9,0x02,0x00,0x00,0x02,0x01,0x0a,0x00,0xe0,0x02,0x00,0x00,0x03,0x01,0x0a,0x00,0x07,0x03,0x00,0x00,
0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,0x73,
0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x02,0x00,0x00,0x00,0x80,0x80,0x80,
0xff,0x09,0x00,0x00,0x00,0x80,0x80,0x80,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x04,0x00,0x00,
0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,0x73,0x00,0x03,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,
0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xc0,0xc0,
0xc0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,
0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,
0x03,0x00,0x00,0x00,0x9e,0x03,0x00,0x00,0x64,0x65,0x66,0x61,0x75,0x6c,0x74,0x00,0x64,0x61,0x74,0x61,
0x00,0x00,0x00,0x00,0xfd,0xfc,0xfb,0xfa,0x00,0x00,0x00,0x00,0x15,0x00,0x00,0x00,0x01,0x00,0x02,0x00,
0xb4,0x00,0x00,0x00,0x01,0x00,0x04,0x00,0xdd,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0x16,0x01,0x00,0x00,
0x02,0x00,0x0a,0x00,0x36,0x01,0x00,0x00,0x03,0x00,0x0a,0x00,0x56,0x01,0x00,0x00,0x04,0x00,0x0a,0x00,
0x76,0x01,0x00,0x00,0x01,0x00,0x09,0x00,0x96,0x01,0x00,0x00,0x01,0x00,0x0d,0x00,0xa6,0x01,0x00,0x00,
0x06,0x00,0x0f,0x00,0xce,0x01,0x00,0x00,0x07,0x00,0x0f,0x00,0xf2,0x01,0x00,0x00,0x06,0x00,0x10,0x00,
0x18,0x02,0x00,0x00,0x07,0x00,0x10,0x00,0x42,0x02,0x00,0x00,0x01,0x01,0x02,0x00,0x6e,0x02,0x00,0x00,
0x01,0x01,0x09,0x00,0x89,0x02,0x00,0x00,0x01,0x03,0x09,0x00,0x99,0x02,0x00,0x00,0x01,0x04,0x09,0x00,
0xc1,0x02,0x00,0x00,0x01,0x05,0x09,0x00,0xe9,0x02,0x00,0x00,0x01,0x01,0x0b,0x00,0x11,0x03,0x00,0x00,
0x01,0x01,0x0a,0x00,0x29,0x03,0x00,0x00,0x02,0x01,0x0a,0x00,0x50,0x03,0x00,0x00,0x03,0x01,0x0a,0x00,
0x77,0x03,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,
0x73,0x61,0x6e,0x73,0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x02,0x00,0x00,
0x00,0x80,0x80,0x80,0xff,0x09,0x00,0x00,0x00,0x80,0x80,0x80,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0x04,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x73,0x61,0x6e,
0x73,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0xbe,0xbe,0xbe,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,
0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x04,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0xff,0xd7,0x00,0xff,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x02,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,
0x00,0x00,0x0c,0x00,0x00,0x00,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,
0x00,0x00,0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,
0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,
0x72,0x61,0x64,0x69,0x6f,0x5f,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,
0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,0x01,0x00,
0x00,0x00,0x0b,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x72,
0x69,0x63,0x6b,0x73,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,
0x00,0x00,0x80,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,
0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,0x00,0x00,
0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0xff,0xff,
0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x74,0x6e,0x5f,0x62,0x6c,0x75,0x65,0x5f,0x6e,0x00,
0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0xff,0xff,0xff,
0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x74,0x6e,0x5f,0x62,0x6c,0x75,0x65,0x5f,0x70,0x00,0x02,
0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,
0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x74,0x6e,0x5f,0x62,0x6c,0x75,0x65,0x5f,0x6f,0x00,0x00,0x00,
0x00,0x00,};
0x00,0x00,0xc0,0xc0,0xc0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,
0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x06,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,
0x00,0x00,0x01,0x00,0x00,0x00,0xbe,0xbe,0xbe,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x09,0x00,
0x00,0x00,0xa0,0xa0,0xa0,0xff,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,
0x00,0x00,0xff,0xd7,0x00,0xff,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x09,0x00,0x00,0x00,0xa0,0xa0,
0xa0,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x63,0x68,0x65,0x63,0x6b,0x65,
0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x75,0x6e,0x63,0x68,0x65,0x63,0x6b,0x65,0x64,0x00,
0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,
0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,0x63,0x68,0x65,0x63,0x6b,0x65,
0x64,0x00,0x02,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,
0x00,0xff,0x01,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x72,0x61,0x64,0x69,0x6f,0x5f,0x75,0x6e,0x63,0x68,
0x65,0x63,0x6b,0x65,0x64,0x00,0x01,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x01,0x00,
0x00,0x00,0x0a,0x00,0x00,0x00,0x62,0x72,0x69,0x63,0x6b,0x73,0x00,0x01,0x00,0x00,0x00,0x06,0x00,0x00,
0x00,0x00,0x80,0x00,0xff,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0x00,0x00,
0xff,0x07,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x0d,0x00,0x00,
0x00,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x80,0x00,
0xff,0x07,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x0d,0x00,0x00,
0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0xff,
0xff,0x07,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x0d,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,
0x00,0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,
0x00,0x62,0x74,0x6e,0x5f,0x62,0x6c,0x75,0x65,0x5f,0x6e,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,
0x09,0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,
0x62,0x74,0x6e,0x5f,0x62,0x6c,0x75,0x65,0x5f,0x70,0x00,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,
0x00,0x00,0x00,0x06,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x62,
0x74,0x6e,0x5f,0x62,0x6c,0x75,0x65,0x5f,0x6f,0x00,0x00,0x00,0x00,0x00,};

1345
log

File diff suppressed because it is too large Load Diff

View File

@ -458,6 +458,10 @@ static void event_type_t_init(lua_State* L) {
lua_pushinteger(L, EVT_PROP_CHANGED);
lua_settable(L, -3);
lua_pushstring(L, "VALUE_CHANGED");
lua_pushinteger(L, EVT_VALUE_CHANGED);
lua_settable(L, -3);
lua_pushstring(L, "PAINT");
lua_pushinteger(L, EVT_PAINT);
lua_settable(L, -3);
@ -880,39 +884,6 @@ static int wrap_label_create(lua_State* L) {
return lftk_newuserdata(L, ret, "/label_t/widget_t", "lftk.label_t");
}
static int wrap_label_set_border(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
uint8_t border = (uint8_t)luaL_checkinteger(L, 2);
ret = (ret_t)label_set_border(widget, border);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_label_set_text_align_h(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
uint8_t text_align_h = (uint8_t)luaL_checkinteger(L, 2);
ret = (ret_t)label_set_text_align_h(widget, text_align_h);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_label_set_text_align_v(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
uint8_t text_align_v = (uint8_t)luaL_checkinteger(L, 2);
ret = (ret_t)label_set_text_align_v(widget, text_align_v);
lua_pushnumber(L, (lua_Number)(ret));
return 1;
}
static int wrap_label_set_text(lua_State* L) {
ret_t ret = 0;
widget_t* widget = (widget_t*)lftk_checkudata(L, 1, "widget_t");
@ -924,30 +895,17 @@ static int wrap_label_set_text(lua_State* L) {
return 1;
}
static const struct luaL_Reg label_t_member_funcs[] = {
{"set_border", wrap_label_set_border},
{"set_text_align_h", wrap_label_set_text_align_h},
{"set_text_align_v", wrap_label_set_text_align_v},
{"set_text", wrap_label_set_text},
{NULL, NULL}};
static const struct luaL_Reg label_t_member_funcs[] = {{"set_text", wrap_label_set_text},
{NULL, NULL}};
static int wrap_label_t_set_prop(lua_State* L) {
label_t* obj = (label_t*)lftk_checkudata(L, 1, "label_t");
const char* name = (const char*)luaL_checkstring(L, 2);
(void)obj;
(void)name;
if (strcmp(name, "border") == 0) {
printf("border is readonly\n");
return 0;
} else if (strcmp(name, "text_align_v") == 0) {
printf("text_align_v is readonly\n");
return 0;
} else if (strcmp(name, "text_align_h") == 0) {
printf("text_align_h is readonly\n");
return 0;
} else {
return wrap_widget_t_set_prop(L);
}
return wrap_widget_t_set_prop(L);
printf("%s: not supported %s\n", __func__, name);
return 0;
}
static int wrap_label_t_get_prop(lua_State* L) {
@ -959,19 +917,6 @@ static int wrap_label_t_get_prop(lua_State* L) {
(void)name;
if (ret) {
lua_pushcfunction(L, ret->func);
return 1;
}
if (strcmp(name, "border") == 0) {
lua_pushinteger(L, (lua_Integer)(obj->border));
return 1;
} else if (strcmp(name, "text_align_v") == 0) {
lua_pushinteger(L, (lua_Integer)(obj->text_align_v));
return 1;
} else if (strcmp(name, "text_align_h") == 0) {
lua_pushinteger(L, (lua_Integer)(obj->text_align_h));
return 1;
} else {
return wrap_widget_t_get_prop(L);

View File

@ -131,8 +131,10 @@ wh_t canvas_measure_text(canvas_t* c, wchar_t* str, int32_t nr) {
for (i = 0; i < nr; i++) {
wchar_t chr = str[i];
if (font_find_glyph(c->font, chr, &g, c->font_size) == RET_OK) {
w += g.w;
if (chr == ' ') {
w += 4;
} else if (font_find_glyph(c->font, chr, &g, c->font_size) == RET_OK) {
w += g.w + 1;
}
}
@ -408,7 +410,7 @@ static ret_t canvas_draw_text_impl(canvas_t* c, wchar_t* str, int32_t nr, xy_t x
for (i = 0; i < nr; i++) {
wchar_t chr = str[i];
if (chr == ' ') {
x += 4 + 1;
x += 4;
} else if (chr == '\r') {
if (str[i + 1] != '\n') {
y += font_size;
@ -424,7 +426,7 @@ static ret_t canvas_draw_text_impl(canvas_t* c, wchar_t* str, int32_t nr, xy_t x
canvas_draw_glyph(c, &g, xx, yy);
x += g.w + 1;
} else {
x += 4 + 1;
x += 4;
}
}

View File

@ -58,10 +58,10 @@ static ret_t check_button_set_value_only(widget_t* widget, bool_t value) {
check_button_t* check_button = CHECK_BUTTON(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
if(check_button->value != value) {
if (check_button->value != value) {
event_t e = {EVT_VALUE_CHANGED, widget};
check_button->value = value;
widget_dispatch(widget, &e);
widget_dispatch(widget, &e);
}
widget->state = WIDGET_STATE_NORMAL;

View File

@ -54,7 +54,7 @@ static const key_type_value_t style_id_name_value[] = {
{"bg-image", TYPE_STRING, STYLE_ID_BG_IMAGE},
{"bg-image-draw-type", TYPE_INT, STYLE_ID_BG_IMAGE_DRAW_TYPE},
{"icon", TYPE_STRING, STYLE_ID_ICON},
};
{"margin", TYPE_INT, STYLE_ID_MARGIN}};
static const key_type_value_t widget_state_name_value[] = {
{"normal", 0, WIDGET_STATE_NORMAL}, {"over", 0, WIDGET_STATE_OVER},
@ -123,6 +123,10 @@ const key_type_value_t* style_id_find(const char* name) {
return find_item(style_id_name_value, ARRAY_SIZE(style_id_name_value), name);
}
const key_type_value_t* style_id_find_by_value(uint32_t value) {
return find_item_by_value(style_id_name_value, ARRAY_SIZE(style_id_name_value), value);
}
const key_type_value_t* widget_state_find(const char* name) {
return find_item(widget_state_name_value, ARRAY_SIZE(widget_state_name_value), name);
}

View File

@ -38,6 +38,8 @@ const key_type_value_t* widget_type_find(const char* name);
const key_type_value_t* widget_type_find_by_value(uint32_t value);
const key_type_value_t* style_id_find(const char* name);
const key_type_value_t* style_id_find_by_value(uint32_t value);
const key_type_value_t* widget_state_find(const char* name);
const key_type_value_t* align_v_type_find(const char* name);
const key_type_value_t* align_h_type_find(const char* name);

View File

@ -105,7 +105,7 @@ typedef enum _event_type_t {
*
*/
EVT_PROP_CHANGED,
/**
* @const EVT_VALUE_CHANGED
*

View File

@ -23,53 +23,9 @@
#include "base/mem.h"
static ret_t label_on_paint_self(widget_t* widget, canvas_t* c) {
xy_t x = 0;
xy_t y = 0;
wh_t w = 0;
uint8_t text_align_h = 0;
uint8_t text_align_v = 0;
style_t* style = &(widget->style);
label_t* label = LABEL(widget);
color_t color = color_init(0xff, 0xff, 0xff, 0xff);
return_value_if_fail(widget != NULL && c != NULL, RET_BAD_PARAMS);
canvas_set_font(c, NULL, 20);
canvas_set_fill_color(c, style_get_color(style, STYLE_ID_BG_COLOR, color));
canvas_set_text_color(c, style_get_color(style, STYLE_ID_TEXT_COLOR, color));
canvas_fill_rect(c, 0, 0, widget->w, widget->h);
w = canvas_measure_text(c, label->text.str, label->text.size);
text_align_h = style_get_int(style, STYLE_ID_TEXT_ALIGN_H, label->text_align_h);
text_align_v = style_get_int(style, STYLE_ID_TEXT_ALIGN_V, label->text_align_v);
switch (text_align_v) {
case ALIGN_V_TOP:
y = label->border;
break;
case ALIGN_V_BOTTOM:
y = widget->h - label->border;
break;
default:
y = (widget->h) >> 1;
break;
}
switch (text_align_h) {
case ALIGN_H_LEFT:
x = label->border;
break;
case ALIGN_H_RIGHT:
x = widget->w - label->border - w;
break;
default:
x = (widget->w - w) >> 1;
break;
}
canvas_draw_text(c, label->text.str, label->text.size, x, y);
return RET_OK;
return widget_paint_helper(widget, c, NULL, &(label->text));
}
ret_t label_set_text(widget_t* widget, const wchar_t* text) {
@ -79,50 +35,12 @@ ret_t label_set_text(widget_t* widget, const wchar_t* text) {
return wstr_set(&(label->text), text);
}
ret_t label_set_border(widget_t* widget, uint8_t border) {
label_t* label = LABEL(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
label->border = border;
return RET_OK;
}
ret_t label_set_text_align_h(widget_t* widget, uint8_t text_align_h) {
label_t* label = LABEL(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
label->text_align_h = text_align_h;
return RET_OK;
}
ret_t label_set_text_align_v(widget_t* widget, uint8_t text_align_v) {
label_t* label = LABEL(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
label->text_align_v = text_align_v;
return RET_OK;
}
static ret_t label_get_prop(widget_t* widget, const char* name, value_t* v) {
label_t* label = LABEL(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (name[0] == 't') {
if (strcmp(name, "text") == 0) {
value_set_wstr(v, label->text.str);
return RET_OK;
} else if (strcmp(name, "text-align-v") == 0) {
value_set_uint8(v, label->text_align_v);
return RET_OK;
} else if (strcmp(name, "text-align-h") == 0) {
value_set_uint8(v, label->text_align_h);
return RET_OK;
}
} else if (name[0] == 'b') {
value_set_uint8(v, label->border);
if (strcmp(name, "text") == 0) {
value_set_wstr(v, label->text.str);
return RET_OK;
}
@ -132,16 +50,8 @@ static ret_t label_get_prop(widget_t* widget, const char* name, value_t* v) {
static ret_t label_set_prop(widget_t* widget, const char* name, const value_t* v) {
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (name[0] == 't') {
if (strcmp(name, "text") == 0) {
return label_set_text(widget, value_wstr(v));
} else if (strcmp(name, "text-align-v") == 0) {
return label_set_text_align_v(widget, value_int(v));
} else if (strcmp(name, "text-align-h") == 0) {
return label_set_text_align_h(widget, value_int(v));
}
} else if (name[0] == 'b') {
return label_set_border(widget, value_int(v));
if (strcmp(name, "text") == 0) {
return label_set_text(widget, value_wstr(v));
}
return RET_NOT_FOUND;
@ -169,7 +79,6 @@ widget_t* label_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
widget_move_resize(widget, x, y, w, h);
widget->vt = &s_label_vtable;
label->border = 3;
wstr_init(&(label->text), 0);
return widget;

View File

@ -36,24 +36,6 @@ BEGIN_C_DECLS
typedef struct _label_t {
widget_t widget;
wstr_t text;
/**
* @property {uint8_t} border
* @readonly
*
*/
uint8_t border;
/**
* @property {uint8_t} text_align_v
* @readonly
*
*/
uint8_t text_align_v;
/**
* @property {uint8_t} text_align_h
* @readonly
*
*/
uint8_t text_align_h;
} label_t;
/**
@ -70,36 +52,6 @@ typedef struct _label_t {
*/
widget_t* label_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method label_set_border
*
* @param {widget_t*} widget label对象
* @param {uint8_t} border
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_border(widget_t* widget, uint8_t border);
/**
* @method label_set_text_align_h
*
* @param {widget_t*} widget label对象
* @param {uint8_t} text_align_h
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_text_align_h(widget_t* widget, uint8_t text_align_h);
/**
* @method label_set_text_align_v
*
* @param {widget_t*} widget label对象
* @param {uint8_t} text_align_v
*
* @return {ret_t} RET_OK表示成功
*/
ret_t label_set_text_align_v(widget_t* widget, uint8_t text_align_v);
/**
* @method label_set_text
*

View File

@ -117,7 +117,13 @@ typedef enum _style_id_t {
* @const STYLE_ID_ICON
*
*/
STYLE_ID_ICON
STYLE_ID_ICON,
/**
* @const STYLE_ID_MARGIN
*
*/
STYLE_ID_MARGIN
} style_id_t;
/**

View File

@ -337,31 +337,31 @@ ret_t widget_paint_helper(widget_t* widget, canvas_t* c, const char* icon, wstr_
color_t bg = style_get_color(style, STYLE_ID_BG_COLOR, trans);
color_t bd = style_get_color(style, STYLE_ID_BORDER_COLOR, trans);
uint16_t font_size = style_get_int(style, STYLE_ID_FONT_SIZE, 20);
if(icon == NULL) {
if (icon == NULL) {
icon = style_get_str(style, STYLE_ID_ICON, NULL);
}
if(bg.rgba.a) {
if (bg.rgba.a) {
canvas_set_fill_color(c, bg);
canvas_fill_rect(c, 0, 0, widget->w, widget->h);
}
if(bd.rgba.a) {
if (bd.rgba.a) {
canvas_set_stroke_color(c, bd);
canvas_stroke_rect(c, 0, 0, widget->w, widget->h);
}
if(image_name != NULL) {
if(image_manager_load(default_im(), image_name, &img) == RET_OK) {
if (image_name != NULL) {
if (image_manager_load(default_im(), image_name, &img) == RET_OK) {
rect_init(dst, 0, 0, widget->w, widget->h);
image_draw_type_t draw_type = (image_draw_type_t)style_get_int(style,
STYLE_ID_BG_IMAGE_DRAW_TYPE, IMAGE_DRAW_CENTER);
image_draw_type_t draw_type =
(image_draw_type_t)style_get_int(style, STYLE_ID_BG_IMAGE_DRAW_TYPE, IMAGE_DRAW_CENTER);
canvas_draw_image_ex(c, &img, draw_type, &dst);
}
}
if(text != NULL && text->size > 0) {
if (text != NULL && text->size > 0) {
color_t tc = style_get_color(style, STYLE_ID_TEXT_COLOR, trans);
const char* font_name = style_get_str(style, STYLE_ID_FONT_NAME, NULL);
@ -369,10 +369,10 @@ ret_t widget_paint_helper(widget_t* widget, canvas_t* c, const char* icon, wstr_
canvas_set_font(c, font_name, font_size);
}
if(icon != NULL && image_manager_load(default_im(), icon, &img) == RET_OK) {
if(text != NULL && text->size > 0) {
if(widget->h > (img.h + font_size)) {
rect_init(dst, 0, 0, widget->w, widget->h-font_size);
if (icon != NULL && image_manager_load(default_im(), icon, &img) == RET_OK) {
if (text != NULL && text->size > 0) {
if (widget->h > (img.h + font_size)) {
rect_init(dst, 0, 0, widget->w, widget->h - font_size);
canvas_draw_image_ex(c, &img, IMAGE_DRAW_CENTER, &dst);
w = canvas_measure_text(c, text->str, text->size);
@ -383,18 +383,44 @@ ret_t widget_paint_helper(widget_t* widget, canvas_t* c, const char* icon, wstr_
rect_init(dst, 0, 0, widget->h, widget->h);
canvas_draw_image_ex(c, &img, IMAGE_DRAW_CENTER, &dst);
x = widget->h+2;
y = (widget->h-font_size) >> 1;
x = widget->h + 2;
y = (widget->h - font_size) >> 1;
canvas_draw_text(c, text->str, text->size, x, y);
}
}else{
} else {
rect_init(dst, 0, 0, widget->w, widget->h);
canvas_draw_image_ex(c, &img, IMAGE_DRAW_CENTER, &dst);
}
} else if(text != NULL && text->size > 0) {
} else if (text != NULL && text->size > 0) {
int32_t align_h = style_get_int(style, STYLE_ID_TEXT_ALIGN_H, ALIGN_H_CENTER);
int32_t align_v = style_get_int(style, STYLE_ID_TEXT_ALIGN_V, ALIGN_V_MIDDLE);
int32_t margin = style_get_int(style, STYLE_ID_MARGIN, 2);
w = canvas_measure_text(c, text->str, text->size);
x = (widget->w - w) >> 1;
y = (widget->h - font_size) >> 1;
switch (align_v) {
case ALIGN_V_TOP:
y = margin;
break;
case ALIGN_V_BOTTOM:
y = widget->h - margin - font_size;
break;
default:
y = (widget->h - font_size) >> 1;
break;
}
switch (align_h) {
case ALIGN_H_LEFT:
x = margin;
break;
case ALIGN_H_RIGHT:
x = widget->w - margin - w;
break;
default:
x = (widget->w - w) >> 1;
break;
}
canvas_draw_text(c, text->str, text->size, x, y);
}

View File

@ -173,6 +173,8 @@ typedef enum _widget_type_t {
*
*/
WIDGET_RADIO_BUTTON,
WIDGET_NR
} widget_type_t;
struct _widget_t;

View File

@ -16,13 +16,13 @@
#define rfpart_(X) (1.0 - fpart_(X))
#define fabs(xx) ((xx) < 0 ? -(xx) : (xx))
#define swap_(a, b) \
do { \
#define swap_(a, b) \
do { \
unsigned int tmp = a; \
a = b; \
b = tmp; \
a = b; \
b = tmp; \
} while (0)
void draw_line(canvas_t* c, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2) {
point_t p;
lcd_t* lcd = c->lcd;
@ -33,7 +33,7 @@ void draw_line(canvas_t* c, unsigned int x1, unsigned int y1, unsigned int x2, u
color_t* color = &(c->lcd->stroke_color);
double dx = (double)x2 - (double)x1;
double dy = (double)y2 - (double)y1;
if (fabs(dx) > fabs(dy)) {
if (x2 < x1) {
swap_(x1, x2);

View File

@ -115,10 +115,10 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
const color_t* data = (color_t*)img->data;
if (src->w == dst->w && src->h == dst->h) {
x = dst->x;
y = dst->y;
const color_t* src_p = data + img->w * src->y + src->x;
x = dst->x;
y = dst->y;
const color_t* src_p = data + img->w * src->y + src->x;
set_window_func(x, y, x + dst->w - 1, y + dst->h - 1);
for (j = 0; j < dh; j++) {
for (i = 0; i < dw; i++) {
@ -138,11 +138,11 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
const color_t* src_p = data + img->w * (sy + (j * sh / dh)) + sx + i * sw / dw;
color_t src_color = src_p[i];
pixel_t color = blend_color(fill_color, src_color, src_color.rgba.a);
x = dst->x + i;
y = dst->y + j;
set_window_func(x, y, x, y);
x = dst->x + i;
y = dst->y + j;
set_window_func(x, y, x, y);
write_data_func(color);
}
}

View File

@ -379,10 +379,10 @@ static const vgcanvas_vtable_t vt = {vgcanvas_agg_reset,
vgcanvas_agg_set_line_join,
vgcanvas_agg_set_line_cap,
vgcanvas_agg_set_miter_limit,
vgcanvas_agg_save,
vgcanvas_agg_restore,
vgcanvas_agg_destroy};
vgcanvas_t* vgcanvas_create(uint32_t w, uint32_t h, uint32_t* buff) {

View File

@ -3,7 +3,7 @@
static ret_t on_changed(void* ctx, event_t* e) {
int* count = (int*)ctx;
if(e->type == EVT_VALUE_CHANGED) {
if (e->type == EVT_VALUE_CHANGED) {
*count += 1;
}
@ -23,19 +23,19 @@ TEST(CheckButton, basic) {
ASSERT_EQ(check_button_set_value(button, TRUE), RET_OK);
ASSERT_EQ(CHECK_BUTTON(button)->value, TRUE);
ASSERT_EQ(count, 1);
ASSERT_EQ(count, 1);
ASSERT_EQ(check_button_set_value(button, FALSE), RET_OK);
ASSERT_EQ(CHECK_BUTTON(button)->value, FALSE);
ASSERT_EQ(count, 2);
ASSERT_EQ(count, 2);
ASSERT_EQ(widget_off(button, id), RET_OK);
ASSERT_EQ(check_button_set_value(button, TRUE), RET_OK);
ASSERT_EQ(CHECK_BUTTON(button)->value, TRUE);
ASSERT_EQ(count, 2);
ASSERT_EQ(count, 2);
ASSERT_EQ(check_button_set_value(button, FALSE), RET_OK);
ASSERT_EQ(CHECK_BUTTON(button)->value, FALSE);
ASSERT_EQ(count, 2);
ASSERT_EQ(count, 2);
}
TEST(CheckButton, radio) {

View File

@ -21,20 +21,5 @@ TEST(Label, basic) {
ASSERT_EQ(widget_get_prop(b, "text", &v2), RET_OK);
ASSERT_EQ(wcscmp(v1.value.wstr, v2.value.wstr), 0);
value_set_uint8(&v1, 1);
ASSERT_EQ(widget_set_prop(b, "text-align-h", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "text-align-h", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
value_set_uint8(&v1, 2);
ASSERT_EQ(widget_set_prop(b, "text-align-v", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "text-align-v", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
value_set_uint8(&v1, 3);
ASSERT_EQ(widget_set_prop(b, "border", &v1), RET_OK);
ASSERT_EQ(widget_get_prop(b, "border", &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
widget_destroy(b);
}

View File

@ -62,15 +62,15 @@ TEST(ThemeGen, style_type) {
theme_t theme;
style_t style;
const char* str =
"<button style_type=\"1:yellow\" state=\"over\" bg-color=\"yellow\" fg-color=\"#fafbfc\" font-name=\"sans\" font-size=\"12\" />\
<button style_type=\"1:yellow\" state=\"pressed\" bg-color=\"rgb(255,255,0)\" fg-color=\"rgba(255,255,0,0.5)\" border-color=\"#ff00ff\" />";
"<button style-type=\"1:yellow\" state=\"over\" bg-color=\"yellow\" fg-color=\"#fafbfc\" font-name=\"sans\" font-size=\"12\" />\
<button style-type=\"1:yellow\" state=\"pressed\" bg-color=\"rgb(255,255,0)\" fg-color=\"rgba(255,255,0,0.5)\" border-color=\"#ff00ff\" />";
xml_gen_buff(str, buff, sizeof(buff));
theme.data = buff;
style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_OVER);
ASSERT_EQ(style.data != NULL, true);
style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_PRESSED);
ASSERT_EQ(style.data != NULL, true);
}

View File

@ -1,6 +1,7 @@
#include "base/array.h"
#include "base/theme.h"
#include "base/widget.h"
#include "tools/theme_gen/theme_gen.h"
#include "gtest/gtest.h"
#include <stdlib.h>
@ -51,7 +52,7 @@ TEST(Theme, saveLoad) {
TEST(Theme, basic) {
uint8_t buff[10240];
uint32_t type_nr = 20;
uint32_t type_nr = WIDGET_NR;
uint32_t state_nr = 5;
uint32_t name_nr = 5;
theme_t t;
@ -60,7 +61,7 @@ TEST(Theme, basic) {
GenThemeData(buff, sizeof(buff), type_nr, state_nr, name_nr);
t.data = buff;
for (uint32_t type = 0; type < type_nr; type++) {
for (uint32_t type = WIDGET_NONE + 1; type < WIDGET_NR; type++) {
for (uint32_t state = 0; state < state_nr; state++) {
s.data = theme_find_style(&t, type, 0, state);
ASSERT_EQ(s.data != NULL, true);

View File

@ -146,10 +146,10 @@
"name": "IMAGE_DRAW_SCALE_AUTO"
},
{
"name": "IMAGE_DRAW_SCALE_X"
"name": "IMAGE_DRAW_SCALE_W"
},
{
"name": "IMAGE_DRAW_SCALE_Y"
"name": "IMAGE_DRAW_SCALE_H"
},
{
"name": "IMAGE_DRAW_REPEAT"
@ -164,10 +164,10 @@
"name": "IMAGE_DRAW_9PATCH"
},
{
"name": "IMAGE_DRAW_3PATCH_H"
"name": "IMAGE_DRAW_3PATCH_X"
},
{
"name": "IMAGE_DRAW_3PATCH_V"
"name": "IMAGE_DRAW_3PATCH_Y"
}
]
},
@ -477,6 +477,9 @@
{
"name": "EVT_PROP_CHANGED"
},
{
"name": "EVT_VALUE_CHANGED"
},
{
"name": "EVT_PAINT"
},
@ -748,48 +751,6 @@
"isConstructor": true,
"return": "widget_t*"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "uint8_t",
"name": "border"
}
],
"name": "label_set_border",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "uint8_t",
"name": "text_align_h"
}
],
"name": "label_set_text_align_h",
"return": "ret_t"
},
{
"params": [
{
"type": "widget_t*",
"name": "widget"
},
{
"type": "uint8_t",
"name": "text_align_v"
}
],
"name": "label_set_text_align_v",
"return": "ret_t"
},
{
"params": [
{
@ -805,23 +766,7 @@
"return": "ret_t"
}
],
"properties": [
{
"type": "uint8_t",
"name": "border",
"readonly": true
},
{
"type": "uint8_t",
"name": "text_align_v",
"readonly": true
},
{
"type": "uint8_t",
"name": "text_align_h",
"readonly": true
}
],
"properties": [],
"header": "base/label.h"
},
{
@ -1112,8 +1057,17 @@
{
"name": "STYLE_ID_BORDER_COLOR"
},
{
"name": "STYLE_ID_BG_IMAGE"
},
{
"name": "STYLE_ID_BG_IMAGE_DRAW_TYPE"
},
{
"name": "STYLE_ID_ICON"
},
{
"name": "STYLE_ID_MARGIN"
}
]
},

View File

@ -20,6 +20,7 @@
*/
#include "theme_gen.h"
#include "base/enums.h"
#include "base/theme.h"
#include "base/types_def.h"
@ -49,21 +50,26 @@ uint8_t* Style::Output(uint8_t* buff, uint32_t max_size) {
uint32_t size = 0;
uint8_t* p = buff;
uint8_t* end = buff + max_size;
const key_type_value_t* witem = widget_type_find_by_value(this->widget_type);
return_value_if_fail(buff != NULL && max_size > 32, NULL);
size = this->int_values.size();
save_uint32(p, size);
// printf(" size=%d widget_type=%d style_type=%d state=%d\n", size, this->widget_type,
// this->style_type, this->state);
printf(" size=%d widget_type=%s style_type=%d state=%d\n", size, witem->name, this->style_type,
this->state);
for (vector<NameIntValue>::iterator i = this->int_values.begin(); i != this->int_values.end();
i++) {
uint32_t name = i->name;
uint32_t value = i->value;
const key_type_value_t* item = style_id_find_by_value(name);
return_value_if_fail((end - p) > 8, NULL);
save_uint32(p, name);
save_uint32(p, value);
printf(" %d=0x%08x\n", name, value);
if (item != NULL) {
printf(" %s=0x%08x\n", item->name, value);
}
}
return_value_if_fail((end - p) > 32, NULL);
@ -75,12 +81,17 @@ uint8_t* Style::Output(uint8_t* buff, uint32_t max_size) {
uint32_t name = i->name;
string value = i->value;
uint32_t s_size = value.size();
const key_type_value_t* item = style_id_find_by_value(name);
return_value_if_fail((end - p) > s_size + 5, NULL);
save_uint32(p, name);
memcpy(p, value.c_str(), s_size + 1);
p += s_size + 1;
printf(" %d=%s\n", name, value.c_str());
if (item != NULL) {
printf(" %s=%s\n", item->name, value.c_str());
}
}
return p;

View File

@ -71,9 +71,15 @@ static void xml_gen_on_start(XmlBuilder* thiz, const char* tag, const char** att
} else {
const key_type_value_t* item = style_id_find(name);
if (item != NULL) {
if(strcmp(name, "bg-image-draw-type") == 0) {
if (strcmp(name, "bg-image-draw-type") == 0) {
const key_type_value_t* dt = image_draw_type_find(value);
s.AddInt(item->value, dt->value);
} else if (strcmp(name, "text-align-h") == 0) {
const key_type_value_t* dt = align_h_type_find(value);
s.AddInt(item->value, dt->value);
} else if (strcmp(name, "text-align-v") == 0) {
const key_type_value_t* dt = align_v_type_find(value);
s.AddInt(item->value, dt->value);
} else if (item->type == TYPE_INT) {
s.AddInt(item->value, atoi(value));
} else if (item->type == TYPE_COLOR) {