为atp_select增加禁止不选择返回的功能

This commit is contained in:
anod 2022-10-15 17:45:36 +08:00
parent 38be558fd9
commit a4c2660f56
3 changed files with 8 additions and 5 deletions

View File

@ -94,6 +94,7 @@ extern atp_error_t atp_select(
INPUT(atp_keyhandler_t) extra_key_handler,
INPUT(atp_callerdata_t) some_data_from_caller,
INPUT(atp_counter_t) index_of_default_selected_item,
INPUT(atp_boolean_t) ignore_no_action,
OUTPUT(atp_itemval_t) value_of_select_item
);

View File

@ -223,7 +223,7 @@ static void draw_options( int start_row, int start_idx, int option_cnt, int sele
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_counter_t index, atp_itemval_t *res )
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_counter_t index, atp_boolean_t action, atp_itemval_t *res )
{
uint8_t title_offset[TITLE_MAX];
int item_sel = index < cnt ? index : 0;
@ -277,7 +277,7 @@ atp_error_t atp_select( atp_text_t title, atp_counter_t cnt, atp_itemprovider_t
}
else
{
return ATP_NO_ACTION;
if( action == 0 ) return ATP_NO_ACTION;
}
}
else if( key & (KEY_X | KEY_Y | KEY_SELECT | KEY_START) )

View File

@ -193,12 +193,14 @@ Result browseFiles(const char *const basePath, char selected[512])
atp_boolean_t scan = 0;
atp_error_t error;
const u32 count = dList->num;
if( count > 0 )
error = atp_select( curDir, count, display_folder, NULL, (atp_callerdata_t)dList, selecting, &value );
else error = atp_show( 1, display_empty, NULL );
u32 pathLen = strlen(curDir);
if( count > 0 )
error = atp_select( curDir, count, display_folder, NULL, (atp_callerdata_t)dList, selecting, strcmp(curDir, FS_DRIVE_NAMES), &value );
else error = atp_show( 1, display_empty, NULL );
if( error == ATP_POWER_OFF )
{
res = error;