mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-08 19:44:45 +08:00
format code
This commit is contained in:
parent
d5cb9571d3
commit
448b30a1f4
@ -41,7 +41,7 @@
|
||||
#include "base/vgcanvas_asset_manager.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_FSCRIPT_EXT
|
||||
#ifdef WITH_FSCRIPT_EXT
|
||||
#ifndef WITH_DATA_READER_WRITER
|
||||
#define WITH_DATA_READER_WRITER
|
||||
#endif /*WITH_DATA_READER_WRITER*/
|
||||
|
@ -2126,8 +2126,8 @@ ret_t canvas_fill_rounded_rect_gradient_ex(canvas_t* c, const rect_t* r, const r
|
||||
uint32_t radius_tr, uint32_t radius_bl,
|
||||
uint32_t radius_br) {
|
||||
color_t color = gradient_get_first_color(gradient);
|
||||
return canvas_fill_rounded_rect_ex(c, r, bg_r, (const color_t*)&color, radius_tl, radius_tr, radius_bl,
|
||||
radius_br);
|
||||
return canvas_fill_rounded_rect_ex(c, r, bg_r, (const color_t*)&color, radius_tl, radius_tr,
|
||||
radius_bl, radius_br);
|
||||
}
|
||||
|
||||
ret_t canvas_stroke_rounded_rect_ex(canvas_t* c, const rect_t* r, const rect_t* bg_r,
|
||||
|
@ -56,7 +56,7 @@ value_change_event_t* value_change_event_cast(event_t* event) {
|
||||
return (value_change_event_t*)event;
|
||||
}
|
||||
|
||||
offset_change_event_t* offset_change_event_cast(event_t* event){
|
||||
offset_change_event_t* offset_change_event_cast(event_t* event) {
|
||||
return_value_if_fail(event != NULL, NULL);
|
||||
return_value_if_fail(event->size == sizeof(offset_change_event_t), NULL);
|
||||
|
||||
@ -177,12 +177,13 @@ event_t* value_change_event_init(value_change_event_t* event, uint32_t type, voi
|
||||
return (event_t*)event;
|
||||
}
|
||||
|
||||
event_t* offset_change_event_init(offset_change_event_t* event, uint32_t type, void* target, float_t old_offset, float_t new_offset) {
|
||||
event_t* offset_change_event_init(offset_change_event_t* event, uint32_t type, void* target,
|
||||
float_t old_offset, float_t new_offset) {
|
||||
return_value_if_fail(event != NULL, NULL);
|
||||
memset(event, 0x00, sizeof(*event));
|
||||
event->e = event_init(type, target);
|
||||
event->e.size = sizeof(*event);
|
||||
|
||||
|
||||
event->old_offset = old_offset;
|
||||
event->new_offset = new_offset;
|
||||
|
||||
|
@ -688,7 +688,8 @@ offset_change_event_t* offset_change_event_cast(event_t* event);
|
||||
*
|
||||
* @return {event_t*} event对象。
|
||||
*/
|
||||
event_t* offset_change_event_init(offset_change_event_t* event, uint32_t type, void* target, float_t old_offset, float_t new_offset);
|
||||
event_t* offset_change_event_init(offset_change_event_t* event, uint32_t type, void* target,
|
||||
float_t old_offset, float_t new_offset);
|
||||
|
||||
/**
|
||||
* @class pointer_event_t
|
||||
|
@ -603,7 +603,7 @@ ret_t widget_set_theme(widget_t* widget, const char* name) {
|
||||
assets_manager_t* am = widget_get_assets_manager(widget);
|
||||
locale_info_t* locale_info = widget_get_locale_info(widget);
|
||||
return_value_if_fail(am != NULL && name != NULL, RET_BAD_PARAMS);
|
||||
|
||||
|
||||
widget_dispatch(window_manager(), will_evt);
|
||||
|
||||
font_manager_unload_all(fm);
|
||||
|
@ -526,8 +526,12 @@ static ret_t scroll_bar_set_prop(widget_t* widget, const char* name, const value
|
||||
return RET_NOT_FOUND;
|
||||
}
|
||||
|
||||
static const char* s_scroll_bar_clone_properties[] = {
|
||||
WIDGET_PROP_MAX, WIDGET_PROP_ROW, WIDGET_PROP_ANIMATABLE, WIDGET_PROP_VALUE, SCROLL_BAR_PROP_ANIMATOR_TIME, NULL};
|
||||
static const char* s_scroll_bar_clone_properties[] = {WIDGET_PROP_MAX,
|
||||
WIDGET_PROP_ROW,
|
||||
WIDGET_PROP_ANIMATABLE,
|
||||
WIDGET_PROP_VALUE,
|
||||
SCROLL_BAR_PROP_ANIMATOR_TIME,
|
||||
NULL};
|
||||
static const char* s_scroll_bar_persitent_properties[] = {WIDGET_PROP_ANIMATABLE, NULL};
|
||||
|
||||
TK_DECL_VTABLE(scroll_bar_mobile) = {.size = sizeof(scroll_bar_t),
|
||||
@ -609,14 +613,14 @@ ret_t scroll_bar_scroll_to(widget_t* widget, int32_t value, int32_t duration) {
|
||||
widget_animator_value_set_params(scroll_bar->wa_value, scroll_bar->value, value);
|
||||
widget_animator_start(scroll_bar->wa_value);
|
||||
widget_animator_on(scroll_bar->wa_value, EVT_ANIM_END, scroll_bar_on_value_animate_end,
|
||||
scroll_bar);
|
||||
scroll_bar);
|
||||
|
||||
if (scroll_bar_is_mobile(widget)) {
|
||||
scroll_bar_hide_by_opacity_animation(widget, TK_ANIMATING_TIME, TK_ANIMATING_TIME);
|
||||
} else {
|
||||
scroll_bar->wa_opactiy = NULL;
|
||||
}
|
||||
} else
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
scroll_bar_set_value(widget, value);
|
||||
|
@ -38,7 +38,8 @@ static uint32_t scroll_view_get_page_max_number(widget_t* widget);
|
||||
static ret_t scroll_view_set_xoffset(scroll_view_t* scroll_view, int32_t xoffset) {
|
||||
offset_change_event_t evt;
|
||||
if (scroll_view->xoffset != xoffset) {
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(scroll_view), (float_t)scroll_view->xoffset_save, (float_t)xoffset);
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(scroll_view),
|
||||
(float_t)scroll_view->xoffset_save, (float_t)xoffset);
|
||||
|
||||
scroll_view->xoffset = xoffset;
|
||||
widget_dispatch(WIDGET(scroll_view), (event_t*)&evt);
|
||||
@ -49,7 +50,8 @@ static ret_t scroll_view_set_xoffset(scroll_view_t* scroll_view, int32_t xoffset
|
||||
static ret_t scroll_view_set_yoffset(scroll_view_t* scroll_view, int32_t yoffset) {
|
||||
offset_change_event_t evt;
|
||||
if (scroll_view->yoffset != yoffset) {
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(scroll_view), (float_t)scroll_view->yoffset_save, (float_t)yoffset);
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(scroll_view),
|
||||
(float_t)scroll_view->yoffset_save, (float_t)yoffset);
|
||||
scroll_view->yoffset = yoffset;
|
||||
widget_dispatch(WIDGET(scroll_view), (event_t*)&evt);
|
||||
}
|
||||
|
@ -349,8 +349,10 @@ static ret_t slide_indicator_default_paint_active_indicator(widget_t* widget, ca
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t slide_indicator_default_paint_indicator_by_transition(widget_t* widget, canvas_t* c, rectf_t* r,
|
||||
color_t color, color_t selected_color, float_t active_offset) {
|
||||
static ret_t slide_indicator_default_paint_indicator_by_transition(widget_t* widget, canvas_t* c,
|
||||
rectf_t* r, color_t color,
|
||||
color_t selected_color,
|
||||
float_t active_offset) {
|
||||
rectf_t new_rect;
|
||||
float_t x, y, w, h, transition_size;
|
||||
color_t new_color = color_init(0, 0, 0, 0);
|
||||
@ -373,7 +375,7 @@ static ret_t slide_indicator_default_paint_indicator_by_transition(widget_t* wid
|
||||
new_color1.rgba.b = selected_color.rgba.b * active_offset;
|
||||
new_color1.rgba.a = selected_color.rgba.a * active_offset;
|
||||
}
|
||||
|
||||
|
||||
transition_size = slide_indicator_get_max_transition_size(slide_indicator) * active_offset;
|
||||
w = r->w + transition_size;
|
||||
h = r->h + transition_size;
|
||||
@ -401,14 +403,16 @@ static ret_t slide_indicator_default_paint_indicator_by_transition(widget_t* wid
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t slide_indicator_paint_one(widget_t* widget, canvas_t* c, rectf_t* r, float_t active_offset) {
|
||||
static ret_t slide_indicator_paint_one(widget_t* widget, canvas_t* c, rectf_t* r,
|
||||
float_t active_offset) {
|
||||
bitmap_t img;
|
||||
style_t* style = widget->astyle;
|
||||
color_t trans = color_init(0, 0, 0, 0);
|
||||
slide_indicator_t* slide_indicator = SLIDE_INDICATOR(widget);
|
||||
color_t color = style_get_color(style, STYLE_ID_FG_COLOR, trans);
|
||||
color_t selected_color = style_get_color(style, STYLE_ID_SELECTED_FG_COLOR, trans);
|
||||
const char* icon = style_get_str(style, active_offset == 1.0f ? STYLE_ID_ACTIVE_ICON : STYLE_ID_ICON, NULL);
|
||||
const char* icon =
|
||||
style_get_str(style, active_offset == 1.0f ? STYLE_ID_ACTIVE_ICON : STYLE_ID_ICON, NULL);
|
||||
|
||||
if (!slide_indicator->transition && icon && widget_load_image(widget, icon, &img) == RET_OK) {
|
||||
int32_t x = r->x + ((int32_t)r->w >> 1);
|
||||
@ -416,7 +420,8 @@ static ret_t slide_indicator_paint_one(widget_t* widget, canvas_t* c, rectf_t* r
|
||||
canvas_draw_icon(c, &img, x, y);
|
||||
} else {
|
||||
if (slide_indicator->transition && 0.0f < active_offset && active_offset < 1.0f) {
|
||||
slide_indicator_default_paint_indicator_by_transition(widget, c, r, color, selected_color, active_offset);
|
||||
slide_indicator_default_paint_indicator_by_transition(widget, c, r, color, selected_color,
|
||||
active_offset);
|
||||
} else if (active_offset == 1.0f) {
|
||||
slide_indicator_default_paint_active_indicator(widget, c, r, selected_color);
|
||||
} else {
|
||||
@ -427,7 +432,8 @@ static ret_t slide_indicator_paint_one(widget_t* widget, canvas_t* c, rectf_t* r
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static float_t slide_indicator_get_offset_by_index(slide_indicator_t* slide_indicator, int32_t index) {
|
||||
static float_t slide_indicator_get_offset_by_index(slide_indicator_t* slide_indicator,
|
||||
int32_t index) {
|
||||
int32_t value = slide_indicator->curr_value;
|
||||
float_t value_offset = slide_indicator->value_offset;
|
||||
if (value_offset > 0.0f) {
|
||||
@ -629,7 +635,8 @@ static ret_t slide_indicator_target_on_value_changing(void* ctx, event_t* e) {
|
||||
offset_change_event_t* evt = (offset_change_event_t*)e;
|
||||
slide_indicator_t* slide_indicator = SLIDE_INDICATOR(indicator);
|
||||
return_value_if_fail(widget != NULL && slide_indicator != NULL && evt != NULL, RET_BAD_PARAMS);
|
||||
if (!slide_indicator->transition || (slide_indicator->transition && slide_indicator->is_value_changing)) {
|
||||
if (!slide_indicator->transition ||
|
||||
(slide_indicator->transition && slide_indicator->is_value_changing)) {
|
||||
slide_indicator->value_offset = 0.0f;
|
||||
return RET_OK;
|
||||
}
|
||||
@ -642,7 +649,7 @@ static ret_t slide_indicator_target_on_value_changing(void* ctx, event_t* e) {
|
||||
value = offset / widget->h;
|
||||
slide_indicator->value_offset = offset / (float_t)widget->h - value;
|
||||
}
|
||||
value = slide_indicator->value + value;
|
||||
value = slide_indicator->value + value;
|
||||
if (slide_indicator->loop) {
|
||||
if (value < 0) {
|
||||
value += slide_indicator->max;
|
||||
|
@ -48,7 +48,7 @@ static bool_t slide_view_is_loopable(slide_view_t* slide_view) {
|
||||
static ret_t slide_view_set_xoffset(slide_view_t* slide_view, int32_t xoffset) {
|
||||
offset_change_event_t evt;
|
||||
if (slide_view->xoffset != xoffset) {
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(slide_view), 0, -(float_t)xoffset);
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(slide_view), 0, -(float_t)xoffset);
|
||||
slide_view->xoffset = xoffset;
|
||||
widget_dispatch(WIDGET(slide_view), (event_t*)&evt);
|
||||
}
|
||||
@ -58,7 +58,7 @@ static ret_t slide_view_set_xoffset(slide_view_t* slide_view, int32_t xoffset) {
|
||||
static ret_t slide_view_set_yoffset(slide_view_t* slide_view, int32_t yoffset) {
|
||||
offset_change_event_t evt;
|
||||
if (slide_view->yoffset != yoffset) {
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(slide_view), 0, -(float_t)yoffset);
|
||||
offset_change_event_init(&evt, EVT_PAGE_CHANGING, WIDGET(slide_view), 0, -(float_t)yoffset);
|
||||
slide_view->yoffset = yoffset;
|
||||
widget_dispatch(WIDGET(slide_view), (event_t*)&evt);
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ ret_t darray_push(darray_t* darray, void* data) {
|
||||
|
||||
ret_t darray_push_unique(darray_t* darray, void* data) {
|
||||
return_value_if_fail(darray != NULL, RET_BAD_PARAMS);
|
||||
if(darray_find_index(darray, data) >= 0) {
|
||||
if (darray_find_index(darray, data) >= 0) {
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
||||
|
@ -549,7 +549,7 @@ TEST(DArrayTest, push_unique) {
|
||||
for (i = 0; i < n; i++) {
|
||||
ASSERT_EQ(darray_push_unique(&darray, tk_pointer_from_int(i)), RET_OK);
|
||||
ASSERT_NE(darray_push_unique(&darray, tk_pointer_from_int(i)), RET_OK);
|
||||
ASSERT_EQ(darray.size, i+1);
|
||||
ASSERT_EQ(darray.size, i + 1);
|
||||
}
|
||||
|
||||
darray_deinit(&darray);
|
||||
|
@ -88,7 +88,7 @@ TEST(Label, add_value) {
|
||||
ASSERT_EQ((int)widget_get_value(label), 10);
|
||||
ASSERT_EQ(widget_add_value(label, -1), RET_OK);
|
||||
ASSERT_EQ((int)widget_get_value(label), 9);
|
||||
|
||||
|
||||
ASSERT_EQ(widget_set_value(label, 100), RET_OK);
|
||||
ASSERT_EQ((int)widget_get_value(label), 100);
|
||||
|
||||
@ -102,7 +102,7 @@ TEST(Label, add_value_int) {
|
||||
ASSERT_EQ(widget_get_value_int(label), 10);
|
||||
ASSERT_EQ(widget_add_value_int(label, -1), RET_OK);
|
||||
ASSERT_EQ(widget_get_value_int(label), 9);
|
||||
|
||||
|
||||
ASSERT_EQ(widget_set_value_int(label, 100), RET_OK);
|
||||
ASSERT_EQ(widget_get_value_int(label), 100);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user