format code

This commit is contained in:
lixianjing 2018-03-31 19:48:56 +08:00
parent 1206d3920b
commit 87805f895c
13 changed files with 555 additions and 746 deletions

View File

@ -9,23 +9,23 @@
</window>
<button>
<style name="default">
<normal bg-color="#f0f0f0" text-color="black" border-color="#a0a0a0" />
<pressed bg-color="#c0c0c0" text-color="black" border-color="#a0a0a0" />
<over bg-color="#e0e0e0" text-color="black" border-color="#a0a0a0" />
<disable bg-color="gray" text-color="#d0d0d0" border-color="#a0a0a0" />
<style name="default" border-color="#a0a0a0" text-color="black">
<normal bg-color="#f0f0f0" />
<pressed bg-color="#c0c0c0" />
<over bg-color="#e0e0e0" />
<disable bg-color="gray" text-color="#d0d0d0" />
</style>
<style name="1:green_btn">
<normal bg-image="green_btn_n" bg-image-draw-type="3patch_x" text-color="white"/>
<pressed bg-image="green_btn_p" bg-image-draw-type="3patch_x" text-color="white"/>
<over bg-image="green_btn_o" bg-image-draw-type="3patch_x" text-color="white"/>
<style name="1:green_btn" bg-image-draw-type="3patch_x" text-color="white">
<normal bg-image="green_btn_n" />
<pressed bg-image="green_btn_p" />
<over bg-image="green_btn_o" />
</style>
<style name="2:red_btn">
<normal bg-image="red_btn_n" bg-image-draw-type="3patch_x" text-color="white"/>
<pressed bg-image="red_btn_p" bg-image-draw-type="3patch_x" text-color="white"/>
<over bg-image="red_btn_o" bg-image-draw-type="3patch_x" text-color="white"/>
<style name="2:red_btn" bg-image-draw-type="3patch_x" text-color="white">
<normal bg-image="red_btn_n" />
<pressed bg-image="red_btn_p" />
<over bg-image="red_btn_o" />
</style>
</button>
@ -58,16 +58,16 @@
</progress_bar>
<check_button>
<style name="default">
<checked bg-color="#f0f0f0" text-color="black" icon="checked" />
<unchecked bg-color="#f0f0f0" text-color="black" icon="unchecked" />
<style name="default" bg-color="#f0f0f0" text-color="black">
<checked icon="checked" />
<unchecked icon="unchecked" />
</style>
</check_button>
<radio_button>
<style name="default">
<checked bg-color="#f0f0f0" text-color="black" icon="radio_checked" />
<unchecked bg-color="#f0f0f0" text-color="black" icon="radio_unchecked" />
<style name="default" bg-color="#f0f0f0" text-color="black">
<checked icon="radio_checked" />
<unchecked icon="radio_unchecked" />
</style>
</radio_button>

View File

@ -180,4 +180,4 @@ const unsigned char image_green_btn_p[] = {
0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,
0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,0x4e,0xab,0x82,0xff,
0x5d,0xb1,0x8c,0xff,0x7d,0xbf,0xa1,0xd7,0x9a,0xcd,0xb6,0x97,0xdb,0xed,0xe5,0x37,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,0xad,0xa6,0x83,0xad,};

View File

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

View File

@ -13,13 +13,13 @@ const unsigned char theme_default[] = {
0x01,0x00,0x11,0x00,0xd9,0x03,0x00,0x00,0x01,0x00,0x12,0x00,0x03,0x04,0x00,0x00,0x01,0x00,0x00,0x00,
0x01,0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,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,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,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,0x02,0x00,0x00,0x00,0x0b,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x06,
0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,
0x00,0x00,0x00,0xf0,0xf0,0xf0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,
0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xc0,0xc0,0xc0,0xff,0x00,
0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0x00,
0x00,0x00,0xff,0x01,0x00,0x00,0x00,0xe0,0xe0,0xe0,0xff,0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x09,
0x00,0x00,0x00,0xa0,0xa0,0xa0,0xff,0x06,0x00,0x00,0x00,0xd0,0xd0,0xd0,0xff,0x01,0x00,0x00,0x00,0xbe,
0xbe,0xbe,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,0x67,0x72,0x65,0x65,0x6e,
0x5f,0x62,0x74,0x6e,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,0x67,0x72,0x65,0x65,0x6e,

View File

@ -11,5 +11,5 @@ const unsigned char ui_dialog1[] = {
0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x59,0x65,0x73,0x00,0x00,0x00,0x01,0x00,0x0a,0x00,0x03,0x03,
0x01,0x00,0x0a,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x28,0x00,0x00,0x00,0x1e,0x00,0x00,0x00,0x6e,0x61,
0x6d,0x65,0x00,0x63,0x61,0x6e,0x63,0x65,0x6c,0x00,0x73,0x74,0x79,0x6c,0x65,0x00,0x32,0x3a,0x72,0x65,
0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x4e,0x6f,0x00,0x00,0x00,0x00,0x5d,0xc3,0x77,
0xff,};
0x64,0x5f,0x62,0x74,0x6e,0x00,0x74,0x65,0x78,0x74,0x00,0x4e,0x6f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,};

File diff suppressed because it is too large Load Diff

View File

@ -51,8 +51,7 @@ static ret_t dialog_set_prop(widget_t* widget, const char* name, const value_t*
return RET_NOT_FOUND;
}
static const widget_vtable_t s_dialog_vtable = {
.get_prop = dialog_get_prop,
static const widget_vtable_t s_dialog_vtable = {.get_prop = dialog_get_prop,
.set_prop = dialog_set_prop};
widget_t* dialog_title_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
@ -129,4 +128,3 @@ ret_t dialog_quit(widget_t* widget, uint32_t code) {
return RET_OK;
}

View File

@ -97,4 +97,3 @@ ret_t dialog_quit(widget_t* widget, uint32_t code);
END_C_DECLS
#endif /*LFTK_DIALOG_H*/

View File

@ -23,7 +23,8 @@
#include "base/widget.h"
#include "base/resource_manager.h"
static const key_type_value_t widget_type_value[] = {{"widget", 0, WIDGET_NONE},
static const key_type_value_t widget_type_value[] = {
{"widget", 0, WIDGET_NONE},
{"window_manager", 0, WIDGET_WINDOW_MANAGER},
{"window", 0, WIDGET_NORMAL_WINDOW},
{"tool_bar", 0, WIDGET_TOOL_BAR},

View File

@ -125,7 +125,9 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
for (i = 0; i < dw; i++) {
color_t src_color = src_p[i];
if (src_color.rgba.a > 7) {
pixel_t color = src_color.rgba.a < 0xfe ? blend_color(fill_color, src_color, src_color.rgba.a) : to_pixel(src_color);
pixel_t color = src_color.rgba.a < 0xfe
? blend_color(fill_color, src_color, src_color.rgba.a)
: to_pixel(src_color);
write_data_func(color);
} else {
write_data_func(fill_pixel);
@ -148,7 +150,9 @@ static ret_t lcd_reg_draw_image(lcd_t* lcd, bitmap_t* img, rect_t* src, rect_t*
uint32_t s = (i * sw) / dw;
color_t src_color = src_p[s];
if (src_color.rgba.a > 7) {
pixel_t color = src_color.rgba.a < 0xfe ? blend_color(fill_color, src_color, src_color.rgba.a) : to_pixel(src_color);
pixel_t color = src_color.rgba.a < 0xfe
? blend_color(fill_color, src_color, src_color.rgba.a)
: to_pixel(src_color);
set_window_func(x, y, x, y);
write_data_func(color);

View File

@ -74,3 +74,25 @@ TEST(ThemeGen, style_type) {
style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_PRESSED);
ASSERT_EQ(style.data != NULL, true);
}
TEST(ThemeGen, inher) {
uint8_t buff[1024];
theme_t theme;
style_t style;
const char* str =
"<button font-size=\"12\"><style name=\"1:yellow\" font-name=\"sans\"><over bg-color=\"yellow\" fg-color=\"#fafbfc\" /></style>\
<style name=\"1:yellow\"><pressed bg-color=\"rgb(255,255,0)\" font-name=\"serif\" font-size=\"14\" /></style></button>";
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);
ASSERT_EQ(style_get_int(&style, STYLE_ID_FONT_SIZE, 0), 12);
ASSERT_EQ(style_get_str(&style, STYLE_ID_FONT_NAME, ""), string("sans"));
style.data = theme_find_style(&theme, WIDGET_BUTTON, 1, WIDGET_STATE_PRESSED);
ASSERT_EQ(style.data != NULL, true);
ASSERT_EQ(style_get_int(&style, STYLE_ID_FONT_SIZE, 0), 14);
ASSERT_EQ(style_get_str(&style, STYLE_ID_FONT_NAME, ""), string("serif"));
}