From c16cecb06213a584c1dec735314be5149eaf1136 Mon Sep 17 00:00:00 2001 From: eshifri Date: Wed, 18 Aug 2021 21:20:33 -0700 Subject: [PATCH 1/2] SD Card Navigation via Touch #310 --- radio/src/gui/colorlcd/radio_sdmanager.cpp | 26 ++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_sdmanager.cpp b/radio/src/gui/colorlcd/radio_sdmanager.cpp index 217d44612..db3fde844 100644 --- a/radio/src/gui/colorlcd/radio_sdmanager.cpp +++ b/radio/src/gui/colorlcd/radio_sdmanager.cpp @@ -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 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()); From 50068899267824f71fb69ae2f948f7ee3ca2eea6 Mon Sep 17 00:00:00 2001 From: eshifri Date: Wed, 18 Aug 2021 21:20:33 -0700 Subject: [PATCH 2/2] SD Card Navigation via Touch #310 --- radio/src/gui/colorlcd/radio_sdmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/radio/src/gui/colorlcd/radio_sdmanager.cpp b/radio/src/gui/colorlcd/radio_sdmanager.cpp index db3fde844..b6508458e 100644 --- a/radio/src/gui/colorlcd/radio_sdmanager.cpp +++ b/radio/src/gui/colorlcd/radio_sdmanager.cpp @@ -211,10 +211,10 @@ class FlashDialog: public FullScreenDialog Progress progress; }; -class sdManagerButton : public TextButton +class SDmanagerButton : public TextButton { public: - sdManagerButton(FormGroup* parent, const rect_t& rect, std::string text, + SDmanagerButton(FormGroup* parent, const rect_t& rect, std::string text, std::function pressHandler = nullptr, WindowFlags windowFlags = BUTTON_BACKGROUND | OPAQUE, LcdFlags textFlags = 0 ) : TextButton(parent, rect, text, pressHandler, windowFlags, textFlags) @@ -272,7 +272,7 @@ void RadioSdManagerPage::build(FormWindow * window) files.sort(compare_nocase); for (auto name: directories) { - auto b = new sdManagerButton(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(); @@ -284,7 +284,7 @@ void RadioSdManagerPage::build(FormWindow * window) } for (auto name: files) { - auto button = new sdManagerButton(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());