|
@ -32,8 +32,8 @@ using namespace ExtUI; |
|
|
using namespace Theme; |
|
|
using namespace Theme; |
|
|
|
|
|
|
|
|
void FilesScreen::onEntry() { |
|
|
void FilesScreen::onEntry() { |
|
|
screen_data.FilesScreen.cur_page = 0; |
|
|
screen_data.Files.cur_page = 0; |
|
|
screen_data.FilesScreen.selected_tag = 0xFF; |
|
|
screen_data.Files.selected_tag = 0xFF; |
|
|
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) |
|
|
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) |
|
|
CLCD::mem_write_32(CLCD::REG::MACRO_0,DL::NOP); |
|
|
CLCD::mem_write_32(CLCD::REG::MACRO_0,DL::NOP); |
|
|
#endif |
|
|
#endif |
|
@ -50,21 +50,21 @@ const char *FilesScreen::getSelectedFilename(bool longName) { |
|
|
void FilesScreen::drawSelectedFile() { |
|
|
void FilesScreen::drawSelectedFile() { |
|
|
FileList files; |
|
|
FileList files; |
|
|
files.seek(getSelectedFileIndex(), true); |
|
|
files.seek(getSelectedFileIndex(), true); |
|
|
screen_data.FilesScreen.flags.is_dir = files.isDir(); |
|
|
screen_data.Files.flags.is_dir = files.isDir(); |
|
|
drawFileButton( |
|
|
drawFileButton( |
|
|
files.filename(), |
|
|
files.filename(), |
|
|
screen_data.FilesScreen.selected_tag, |
|
|
screen_data.Files.selected_tag, |
|
|
screen_data.FilesScreen.flags.is_dir, |
|
|
screen_data.Files.flags.is_dir, |
|
|
true |
|
|
true |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint16_t FilesScreen::getSelectedFileIndex() { |
|
|
uint16_t FilesScreen::getSelectedFileIndex() { |
|
|
return getFileForTag(screen_data.FilesScreen.selected_tag); |
|
|
return getFileForTag(screen_data.Files.selected_tag); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint16_t FilesScreen::getFileForTag(uint8_t tag) { |
|
|
uint16_t FilesScreen::getFileForTag(uint8_t tag) { |
|
|
return screen_data.FilesScreen.cur_page * files_per_page + tag - 2; |
|
|
return screen_data.Files.cur_page * files_per_page + tag - 2; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#if ENABLED(TOUCH_UI_PORTRAIT) |
|
|
#if ENABLED(TOUCH_UI_PORTRAIT) |
|
@ -106,15 +106,15 @@ void FilesScreen::drawFileButton(const char* filename, uint8_t tag, bool is_dir, |
|
|
|
|
|
|
|
|
void FilesScreen::drawFileList() { |
|
|
void FilesScreen::drawFileList() { |
|
|
FileList files; |
|
|
FileList files; |
|
|
screen_data.FilesScreen.num_page = max(1,ceil(float(files.count()) / files_per_page)); |
|
|
screen_data.Files.num_page = max(1,ceil(float(files.count()) / files_per_page)); |
|
|
screen_data.FilesScreen.cur_page = min(screen_data.FilesScreen.cur_page, screen_data.FilesScreen.num_page-1); |
|
|
screen_data.Files.cur_page = min(screen_data.Files.cur_page, screen_data.Files.num_page-1); |
|
|
screen_data.FilesScreen.flags.is_root = files.isAtRootDir(); |
|
|
screen_data.Files.flags.is_root = files.isAtRootDir(); |
|
|
|
|
|
|
|
|
#undef MARGIN_T |
|
|
#undef MARGIN_T |
|
|
#undef MARGIN_B |
|
|
#undef MARGIN_B |
|
|
#define MARGIN_T 0 |
|
|
#define MARGIN_T 0 |
|
|
#define MARGIN_B 0 |
|
|
#define MARGIN_B 0 |
|
|
uint16_t fileIndex = screen_data.FilesScreen.cur_page * files_per_page; |
|
|
uint16_t fileIndex = screen_data.Files.cur_page * files_per_page; |
|
|
for (uint8_t i = 0; i < files_per_page; i++, fileIndex++) { |
|
|
for (uint8_t i = 0; i < files_per_page; i++, fileIndex++) { |
|
|
if (files.seek(fileIndex)) { |
|
|
if (files.seek(fileIndex)) { |
|
|
drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); |
|
|
drawFileButton(files.filename(), getTagForLine(i), files.isDir(), false); |
|
@ -126,8 +126,8 @@ void FilesScreen::drawFileList() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void FilesScreen::drawHeader() { |
|
|
void FilesScreen::drawHeader() { |
|
|
const bool prev_enabled = screen_data.FilesScreen.cur_page > 0; |
|
|
const bool prev_enabled = screen_data.Files.cur_page > 0; |
|
|
const bool next_enabled = screen_data.FilesScreen.cur_page < (screen_data.FilesScreen.num_page - 1); |
|
|
const bool next_enabled = screen_data.Files.cur_page < (screen_data.Files.num_page - 1); |
|
|
|
|
|
|
|
|
#undef MARGIN_T |
|
|
#undef MARGIN_T |
|
|
#undef MARGIN_B |
|
|
#undef MARGIN_B |
|
@ -136,7 +136,7 @@ void FilesScreen::drawHeader() { |
|
|
|
|
|
|
|
|
char str[16]; |
|
|
char str[16]; |
|
|
sprintf_P(str, PSTR("Page %d of %d"), |
|
|
sprintf_P(str, PSTR("Page %d of %d"), |
|
|
screen_data.FilesScreen.cur_page + 1, screen_data.FilesScreen.num_page); |
|
|
screen_data.Files.cur_page + 1, screen_data.Files.num_page); |
|
|
|
|
|
|
|
|
CommandProcessor cmd; |
|
|
CommandProcessor cmd; |
|
|
cmd.colors(normal_btn) |
|
|
cmd.colors(normal_btn) |
|
@ -158,8 +158,8 @@ void FilesScreen::drawFooter() { |
|
|
#define MARGIN_T 5 |
|
|
#define MARGIN_T 5 |
|
|
#define MARGIN_B 5 |
|
|
#define MARGIN_B 5 |
|
|
#endif |
|
|
#endif |
|
|
const bool has_selection = screen_data.FilesScreen.selected_tag != 0xFF; |
|
|
const bool has_selection = screen_data.Files.selected_tag != 0xFF; |
|
|
const uint8_t back_tag = screen_data.FilesScreen.flags.is_root ? 240 : 245; |
|
|
const uint8_t back_tag = screen_data.Files.flags.is_root ? 240 : 245; |
|
|
const uint8_t y = GRID_ROWS - footer_h + 1; |
|
|
const uint8_t y = GRID_ROWS - footer_h + 1; |
|
|
const uint8_t h = footer_h; |
|
|
const uint8_t h = footer_h; |
|
|
|
|
|
|
|
@ -171,7 +171,7 @@ void FilesScreen::drawFooter() { |
|
|
.enabled(has_selection) |
|
|
.enabled(has_selection) |
|
|
.colors(has_selection ? action_btn : normal_btn); |
|
|
.colors(has_selection ? action_btn : normal_btn); |
|
|
|
|
|
|
|
|
if (screen_data.FilesScreen.flags.is_dir) |
|
|
if (screen_data.Files.flags.is_dir) |
|
|
cmd.tag(244).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_OPEN)); |
|
|
cmd.tag(244).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_OPEN)); |
|
|
else |
|
|
else |
|
|
cmd.tag(243).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_PRINT)); |
|
|
cmd.tag(243).button(BTN_POS(1, y), BTN_SIZE(3,h), GET_TEXT_F(MSG_BUTTON_PRINT)); |
|
@ -186,8 +186,8 @@ void FilesScreen::onRedraw(draw_mode_t what) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void FilesScreen::gotoPage(uint8_t page) { |
|
|
void FilesScreen::gotoPage(uint8_t page) { |
|
|
screen_data.FilesScreen.selected_tag = 0xFF; |
|
|
screen_data.Files.selected_tag = 0xFF; |
|
|
screen_data.FilesScreen.cur_page = page; |
|
|
screen_data.Files.cur_page = page; |
|
|
CommandProcessor cmd; |
|
|
CommandProcessor cmd; |
|
|
cmd.cmd(CMD_DLSTART) |
|
|
cmd.cmd(CMD_DLSTART) |
|
|
.cmd(CLEAR_COLOR_RGB(bg_color)) |
|
|
.cmd(CLEAR_COLOR_RGB(bg_color)) |
|
@ -201,13 +201,13 @@ bool FilesScreen::onTouchEnd(uint8_t tag) { |
|
|
switch (tag) { |
|
|
switch (tag) { |
|
|
case 240: GOTO_PREVIOUS(); return true; |
|
|
case 240: GOTO_PREVIOUS(); return true; |
|
|
case 241: |
|
|
case 241: |
|
|
if (screen_data.FilesScreen.cur_page > 0) { |
|
|
if (screen_data.Files.cur_page > 0) { |
|
|
gotoPage(screen_data.FilesScreen.cur_page-1); |
|
|
gotoPage(screen_data.Files.cur_page-1); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 242: |
|
|
case 242: |
|
|
if (screen_data.FilesScreen.cur_page < (screen_data.FilesScreen.num_page-1)) { |
|
|
if (screen_data.Files.cur_page < (screen_data.Files.num_page-1)) { |
|
|
gotoPage(screen_data.FilesScreen.cur_page+1); |
|
|
gotoPage(screen_data.Files.cur_page+1); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 243: |
|
|
case 243: |
|
@ -229,18 +229,18 @@ bool FilesScreen::onTouchEnd(uint8_t tag) { |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
if (tag < 240) { |
|
|
if (tag < 240) { |
|
|
screen_data.FilesScreen.selected_tag = tag; |
|
|
screen_data.Files.selected_tag = tag; |
|
|
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) |
|
|
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) |
|
|
if (FTDI::ftdi_chip >= 810) { |
|
|
if (FTDI::ftdi_chip >= 810) { |
|
|
const char *longFilename = getSelectedLongFilename(); |
|
|
const char *longFilename = getSelectedLongFilename(); |
|
|
if (longFilename[0]) { |
|
|
if (longFilename[0]) { |
|
|
CommandProcessor cmd; |
|
|
CommandProcessor cmd; |
|
|
uint16_t text_width = cmd.font(font_medium).text_width(longFilename); |
|
|
uint16_t text_width = cmd.font(font_medium).text_width(longFilename); |
|
|
screen_data.FilesScreen.scroll_pos = 0; |
|
|
screen_data.Files.scroll_pos = 0; |
|
|
if (text_width > display_width) |
|
|
if (text_width > display_width) |
|
|
screen_data.FilesScreen.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R; |
|
|
screen_data.Files.scroll_max = text_width - display_width + MARGIN_L + MARGIN_R; |
|
|
else |
|
|
else |
|
|
screen_data.FilesScreen.scroll_max = 0; |
|
|
screen_data.Files.scroll_max = 0; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
@ -254,9 +254,9 @@ void FilesScreen::onIdle() { |
|
|
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) |
|
|
#if ENABLED(SCROLL_LONG_FILENAMES) && (FTDI_API_LEVEL >= 810) |
|
|
if (FTDI::ftdi_chip >= 810) { |
|
|
if (FTDI::ftdi_chip >= 810) { |
|
|
CLCD::mem_write_32(CLCD::REG::MACRO_0, |
|
|
CLCD::mem_write_32(CLCD::REG::MACRO_0, |
|
|
VERTEX_TRANSLATE_X(-int32_t(screen_data.FilesScreen.scroll_pos))); |
|
|
VERTEX_TRANSLATE_X(-int32_t(screen_data.Files.scroll_pos))); |
|
|
if (screen_data.FilesScreen.scroll_pos < screen_data.FilesScreen.scroll_max * 16) |
|
|
if (screen_data.Files.scroll_pos < screen_data.Files.scroll_max * 16) |
|
|
screen_data.FilesScreen.scroll_pos++; |
|
|
screen_data.Files.scroll_pos++; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|