mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-29 18:48:09 +08:00
format code
This commit is contained in:
parent
22b6fc8bc1
commit
e33e999585
@ -32,11 +32,11 @@ typedef struct _key_pressed_info_t {
|
||||
uint32_t key;
|
||||
uint32_t emitted;
|
||||
uint64_t time;
|
||||
/*
|
||||
/*
|
||||
* 窗口切换时,旧窗口按下的键,一直不松开,会持续触发PRESS,可能会干扰新窗口的用户功能。
|
||||
* 所在窗口切换时,abort全部已经按下的键,直到按键松开。
|
||||
*/
|
||||
bool_t should_abort;
|
||||
bool_t should_abort;
|
||||
} key_pressed_info_t;
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ static row_info_t* text_edit_single_line_layout_line(text_edit_t* text_edit, uin
|
||||
caret_x = caret_text_w;
|
||||
caret_left = layout_info->margin_l + caret_x;
|
||||
view_left = layout_info->ox + layout_info->margin_l;
|
||||
if ((text_w < layout_info->w) ||
|
||||
if ((text_w < layout_info->w) ||
|
||||
(view_left + c->font_size >= caret_left && state->cursor == text->size)) {
|
||||
layout_info->ox = 0;
|
||||
if (align_h == ALIGN_H_RIGHT) {
|
||||
|
@ -430,7 +430,7 @@ ret_t value_deep_copy(value_t* dst, const value_t* src) {
|
||||
case VALUE_TYPE_UBJSON: {
|
||||
if (src->value.binary_data.data != NULL) {
|
||||
uint32_t size = src->value.binary_data.size;
|
||||
void* data = TKMEM_ALLOC(size);
|
||||
void* data = TKMEM_ALLOC(size);
|
||||
return_value_if_fail(data != NULL, RET_OOM);
|
||||
|
||||
dst->free_handle = TRUE;
|
||||
@ -567,7 +567,7 @@ bool_t value_equal(const value_t* v, const value_t* other) {
|
||||
case VALUE_TYPE_WSTRING: {
|
||||
return (v->value.wstr == other->value.wstr) || tk_wstr_eq(v->value.wstr, other->value.wstr);
|
||||
}
|
||||
case VALUE_TYPE_BINARY:
|
||||
case VALUE_TYPE_BINARY:
|
||||
case VALUE_TYPE_UBJSON: {
|
||||
return (v->value.binary_data.data == other->value.binary_data.data);
|
||||
}
|
||||
@ -707,7 +707,7 @@ value_t* value_dup_binary_data(value_t* v, const void* data, uint32_t size) {
|
||||
v->value.binary_data.size = size;
|
||||
v->free_handle = TRUE;
|
||||
|
||||
return v;
|
||||
return v;
|
||||
}
|
||||
|
||||
binary_data_t* value_binary_data(const value_t* v) {
|
||||
|
@ -209,9 +209,10 @@ static ret_t label_paint_text(widget_t* widget, canvas_t* c, const wchar_t* str,
|
||||
int32_t margin = style_get_int(style, STYLE_ID_MARGIN, 2);
|
||||
int32_t w = widget->w - margin - margin;
|
||||
|
||||
return_value_if_fail(label_line_parser_init(&p, c, widget->text.str, widget->text.size,
|
||||
c->font_size, w, label->line_wrap, label->word_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(
|
||||
label_line_parser_init(&p, c, widget->text.str, widget->text.size, c->font_size, w,
|
||||
label->line_wrap, label->word_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
|
||||
if (p.total_lines > 1) {
|
||||
return label_paint_text_mlines(widget, c, &p);
|
||||
@ -294,9 +295,10 @@ ret_t label_resize_to_content(widget_t* widget, uint32_t min_w, uint32_t max_w,
|
||||
tmp_w = max_w - 2 * margin;
|
||||
}
|
||||
}
|
||||
return_value_if_fail(label_line_parser_init(&p, c, widget->text.str, widget->text.size,
|
||||
c->font_size, tmp_w, label->line_wrap, label->word_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(
|
||||
label_line_parser_init(&p, c, widget->text.str, widget->text.size, c->font_size, tmp_w,
|
||||
label->line_wrap, label->word_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
|
||||
h = p.total_lines * line_height + 2 * margin;
|
||||
h = tk_clampi(h, min_h, max_h);
|
||||
@ -399,9 +401,10 @@ static ret_t label_auto_adjust_size(widget_t* widget) {
|
||||
w = tmp_w + 2 * margin;
|
||||
}
|
||||
|
||||
return_value_if_fail(label_line_parser_init(&p, c, widget->text.str, widget->text.size,
|
||||
c->font_size, tmp_w, label->line_wrap, label->word_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
return_value_if_fail(
|
||||
label_line_parser_init(&p, c, widget->text.str, widget->text.size, c->font_size, tmp_w,
|
||||
label->line_wrap, label->word_wrap) == RET_OK,
|
||||
RET_BAD_PARAMS);
|
||||
|
||||
widget->w = w;
|
||||
widget->h = line_height * p.total_lines;
|
||||
@ -430,7 +433,8 @@ static ret_t label_on_event(widget_t* widget, event_t* e) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static const char* const s_label_properties[] = {WIDGET_PROP_LENGTH, WIDGET_PROP_LINE_WRAP, WIDGET_PROP_WORD_WRAP, NULL};
|
||||
static const char* const s_label_properties[] = {WIDGET_PROP_LENGTH, WIDGET_PROP_LINE_WRAP,
|
||||
WIDGET_PROP_WORD_WRAP, NULL};
|
||||
|
||||
TK_DECL_VTABLE(label) = {.size = sizeof(label_t),
|
||||
.type = WIDGET_TYPE_LABEL,
|
||||
|
@ -195,18 +195,18 @@ TEST(InputDeviceStatus, should_abort) {
|
||||
|
||||
input_device_status_abort_all_pressed_keys(ids);
|
||||
|
||||
s_log = "";
|
||||
s_log = "";
|
||||
e.key = TK_KEY_CAPSLOCK;
|
||||
e.e = event_init(EVT_KEY_DOWN, NULL);
|
||||
input_device_status_on_input_event(ids, w, (event_t*)(&e));
|
||||
ASSERT_EQ(s_log, "");
|
||||
|
||||
s_log = "";
|
||||
s_log = "";
|
||||
e.e = event_init(EVT_KEY_UP, NULL);
|
||||
input_device_status_on_input_event(ids, w, (event_t*)(&e));
|
||||
ASSERT_EQ(s_log, "");
|
||||
|
||||
s_log = "";
|
||||
|
||||
s_log = "";
|
||||
e.key = TK_KEY_CAPSLOCK;
|
||||
e.e = event_init(EVT_KEY_DOWN, NULL);
|
||||
input_device_status_on_input_event(ids, w, (event_t*)(&e));
|
||||
|
@ -280,18 +280,18 @@ TEST(ValueTest, deepcopy_binary) {
|
||||
value_t v;
|
||||
value_t other;
|
||||
const char* str = "str";
|
||||
binary_data_t* bin1 = NULL;
|
||||
binary_data_t* bin2 = NULL;
|
||||
binary_data_t* bin1 = NULL;
|
||||
binary_data_t* bin2 = NULL;
|
||||
|
||||
ASSERT_EQ(&other, value_set_binary_data(&other, (void*)str, 4));
|
||||
ASSERT_EQ(value_deep_copy(&v, &other), RET_OK);
|
||||
|
||||
bin1 = value_binary_data(&v);
|
||||
bin2 = value_binary_data(&other);
|
||||
bin1 = value_binary_data(&v);
|
||||
bin2 = value_binary_data(&other);
|
||||
|
||||
ASSERT_STREQ((const char*)(bin1->data), str);
|
||||
ASSERT_STREQ((const char*)(bin2->data), str);
|
||||
ASSERT_EQ(bin1->data != bin2->data, true);
|
||||
ASSERT_STREQ((const char*)(bin1->data), str);
|
||||
ASSERT_STREQ((const char*)(bin2->data), str);
|
||||
ASSERT_EQ(bin1->data != bin2->data, true);
|
||||
|
||||
value_reset(&v);
|
||||
value_reset(&other);
|
||||
|
Loading…
Reference in New Issue
Block a user