From 7b137f39e4283c0d2353ba0891cd6913cbfc2f6d Mon Sep 17 00:00:00 2001 From: anod <182859762@qq.com> Date: Tue, 11 Oct 2022 20:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BB=A3=E7=A0=81=E6=89=93?= =?UTF-8?q?=E5=AE=8F+=E5=AD=97=E9=9D=A2=E5=B8=B8=E9=87=8F=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E7=AC=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/arm11/atp.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/source/arm11/atp.c b/source/arm11/atp.c index b7689f9..5df5834 100644 --- a/source/arm11/atp.c +++ b/source/arm11/atp.c @@ -50,14 +50,14 @@ const char *acf_put_text(int x, int y, int width, int height, int maxwidth, u8 c //--------------------------------------------------- -#define CONTAINER_LEFTTOP_X 20u -#define CONTAINER_LEFTTOP_Y 15u -#define CONTAINER_RECT_WIDTH 282u -#define CONTAINER_MAX_LINES 13u -#define WINDOW_WIDTH 320u -#define WINDOW_HEIGHT 240u +#define CONTAINER_LEFTTOP_X 20 +#define CONTAINER_LEFTTOP_Y 15 +#define CONTAINER_RECT_WIDTH 282 +#define CONTAINER_MAX_LINES 13 +#define WINDOW_WIDTH 320 +#define WINDOW_HEIGHT 240 -#define FONT_HEIGHT 15u +#define FONT_HEIGHT 15 static void screen_clean() { @@ -195,6 +195,16 @@ static void draw_options( int start_row, int start_idx, int option_cnt, int sele } #define SELECTED_ROW(top, len, sel) ((top) < (len) ? (len)-(top)+(sel) : (sel)+(len)-(top)) +#define REFRESH_PAGE {\ + if( idx_top < title_len )\ + {\ + void *title_data[2] = {(void*)title, (void*)title_offset};\ + container_paint( title_paint, title_data, title_len-idx_top, idx_top );\ + draw_options( title_len - idx_top, 0, cnt, item_sel, provider, data );\ + }\ + else draw_options( 0, idx_top - title_len, cnt, item_sel, provider, data );\ + } + atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t provider, atp_keyhandler_t handler, atp_callerdata_t data, atp_itemval_t *res ) { uint8_t title_offset[TITLE_MAX]; @@ -252,13 +262,7 @@ atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t switch( opt ) { case ATP_PAGE_REFRESH: - if( idx_top < title_len ) - { - void *title_data[2] = {(void*)title, (void*)title_offset}; - container_paint( title_paint, title_data, title_len-idx_top, idx_top ); - draw_options( title_len - idx_top, 0, cnt, item_sel, provider, data ); - } - else draw_options( 0, idx_top - title_len, cnt, item_sel, provider, data ); + REFRESH_PAGE; break; case ATP_PAGE_UPDATE: draw_one_option( item_sel, item_sel, SELECTED_ROW(idx_top, title_len, item_sel), provider, data ); @@ -292,13 +296,7 @@ atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t // 更新view if( full_refresh ) {// 重新绘制全部 - if( idx_top < title_len ) - { - void *title_data[2] = {(void*)title, (void*)title_offset}; - container_paint( title_paint, title_data, title_len-idx_top, idx_top ); - draw_options( title_len - idx_top, 0, cnt, sel, provider, data ); - } - else draw_options( 0, idx_top - title_len, cnt, sel, provider, data ); + REFRESH_PAGE; } else {// 重新绘制item_sel和sel