Cosmetics for easier reuse

This commit is contained in:
Bertrand Songis
2020-04-15 18:20:54 +02:00
parent a12865277b
commit 83e6f94f8a
4 changed files with 19 additions and 6 deletions
+11
View File
@@ -45,6 +45,17 @@ Choice::Choice(FormGroup * parent, const rect_t & rect, const char * values[], i
}
}
Choice::Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int16_t vmin, int16_t vmax,
std::function<int16_t()> getValue, std::function<void(int16_t)> setValue, WindowFlags windowFlags) :
ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags),
values(std::move(values)),
vmin(vmin),
vmax(vmax),
getValue(std::move(getValue)),
setValue(std::move(setValue))
{
}
Choice::Choice(FormGroup * parent, const rect_t & rect, const char * values, int16_t vmin, int16_t vmax,
std::function<int16_t()> getValue, std::function<void(int16_t)> setValue, WindowFlags windowFlags) :
ChoiceBase(parent, rect, CHOICE_TYPE_DROPOWN, windowFlags),
+1
View File
@@ -48,6 +48,7 @@ class ChoiceBase : public FormField {
class Choice : public ChoiceBase {
public:
Choice(FormGroup * parent, const rect_t & rect, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
Choice(FormGroup * parent, const rect_t & rect, std::vector<std::string> values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
Choice(FormGroup * parent, const rect_t & rect, const char * values[], int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
Choice(FormGroup * parent, const rect_t & rect, const char * values, int16_t vmin, int16_t vmax, std::function<int16_t()> getValue, std::function<void(int16_t)> setValue = nullptr, WindowFlags windowFlags = 0);
-6
View File
@@ -26,12 +26,6 @@
extern const char STR_SDCARD[];
extern const char STR_NO_FILES_ON_SD[];
// comparison, not case sensitive.
bool compare_nocase(const std::string &first, const std::string &second)
{
return strcasecmp(first.c_str(), second.c_str()) < 0;
}
FileChoice::FileChoice(FormGroup * parent, const rect_t & rect, std::string folder, const char * extension, int maxlen, std::function<std::string()> getValue, std::function<void(std::string)> setValue):
ChoiceBase(parent, rect, CHOICE_TYPE_FOLDER),
folder(std::move(folder)),
+7
View File
@@ -20,6 +20,7 @@
#ifndef _LIBOPEUI_FILE_H_
#define _LIBOPEUI_FILE_H_
#include <string>
#include <inttypes.h>
#include "ff.h"
@@ -29,4 +30,10 @@ const char * getFileExtension(const char * filename, uint8_t size = 0, uint8_t e
bool isExtensionMatching(const char * extension, const char * pattern, char * match = nullptr);
FRESULT sdReadDir(DIR * dir, FILINFO * fno, bool & firstTime);
// comparison, not case sensitive.
inline bool compare_nocase(const std::string &first, const std::string &second)
{
return strcasecmp(first.c_str(), second.c_str()) < 0;
}
#endif