More Improvements on SoundBoard

Optimizing and fixing
This commit is contained in:
ITAxReal 2020-08-28 23:59:33 +03:00
parent 668afccc28
commit 8a4e6492d9
2 changed files with 17 additions and 3 deletions

View File

@ -141,7 +141,7 @@ void SoundBoardView::refresh_list() {
auto reader = std::make_unique<WAVFileReader>();
file_list.clear();
uint32_t c_page = page;
c_page = page;
// List directories and files, put directories up top
uint32_t count = 0;
@ -231,6 +231,7 @@ SoundBoardView::SoundBoardView(
&page_info,
&check_loop,
&check_random,
&button_prev_page,
&button_next_page,
&tx_view
});
@ -240,6 +241,13 @@ SoundBoardView::SoundBoardView(
button_next_page.on_select = [this](Button&) {
this->refresh_list();
};
button_prev_page.on_select = [this](Button&) {
if (c_page == 1) return;
if (c_page == 2) page = 1;
page = c_page - 1;
refresh_list();
};
//text_title.set(to_string_dec_uint(file_list.size()));

View File

@ -59,6 +59,7 @@ private:
uint32_t playing_id { };
uint32_t page = 1;
uint32_t c_page = 1;
std::vector<std::filesystem::path> file_list { };
@ -86,10 +87,15 @@ private:
};
Button button_next_page {
{ 18 * 10, 25 * 8, 10 * 4, 2 * 16 },
{ 30 * 7, 25 * 8, 10 * 3, 2 * 14 },
"=>"
};
Button button_prev_page {
{ 17 * 10, 25 * 8, 10 * 3, 2 * 14 },
"<="
};
Text page_info {
{ 0, 30 * 8 - 4, 30 * 8, 16 }
};
@ -124,7 +130,7 @@ private:
};
Checkbox check_random {
{ 10 * 8, 25 * 8 + 4 },
{ 10 * 7, 25 * 8 + 4 },
6,
"Random"
};