Merge pull request #602 from eshifri/eshifri/SD_Navigation

Highlight file/folder when selected by touch before release allowing change of mind
This commit is contained in:
Peter Feerick
2021-08-22 19:07:45 +10:00
committed by GitHub
+24 -2
View File
@@ -211,6 +211,28 @@ class FlashDialog: public FullScreenDialog
Progress progress;
};
class SDmanagerButton : public TextButton
{
public:
SDmanagerButton(FormGroup* parent, const rect_t& rect, std::string text,
std::function<uint8_t(void)> pressHandler = nullptr,
WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE,
LcdFlags textFlags = 0 ) : TextButton(parent, rect, text, pressHandler, windowFlags, textFlags)
{
};
#if defined(HARDWARE_TOUCH)
bool onTouchStart(coord_t x, coord_t y) override
{
if (enabled) {
if (!(windowFlags & NO_FOCUS)) {
setFocus(SET_FOCUS_DEFAULT);
}
}
return true;
}
#endif
};
void RadioSdManagerPage::build(FormWindow * window)
{
FormGridLayout grid;
@@ -250,7 +272,7 @@ void RadioSdManagerPage::build(FormWindow * window)
files.sort(compare_nocase);
for (auto name: directories) {
auto b = new TextButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t {
auto b = new SDmanagerButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t {
std::string fullpath = currentPath + "/" + name;
f_chdir((TCHAR*)fullpath.c_str());
window->clear();
@@ -262,7 +284,7 @@ void RadioSdManagerPage::build(FormWindow * window)
}
for (auto name: files) {
auto button = new TextButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t {
auto button = new SDmanagerButton(window, grid.getLabelSlot(), name, [=]() -> uint8_t {
auto menu = new Menu(window);
f_chdir(currentPath.c_str());
const char *ext = getFileExtension(name.data());