chore(color): LVGL update, translation strings for theme file carousel (#3278)
* Use StaticText instead of 'paint' function for 'loading' message in theme file carousel, Add message strings to translation files. * Update translation. * Update translation. * Update translation. * Update translation. * Update translation. * Update translation. * Update translation.
This commit is contained in:
@@ -25,8 +25,6 @@ extern inline tmr10ms_t getTicks()
|
||||
return g_tmr10ms;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FileCarosell::FileCarosell(Window *parent, const rect_t &rect,
|
||||
std::vector<std::string> fileNames) :
|
||||
FormGroup(parent, rect, NO_FOCUS | FORM_NO_BORDER),
|
||||
@@ -34,13 +32,10 @@ FileCarosell::FileCarosell(Window *parent, const rect_t &rect,
|
||||
fp(new FilePreview(this, {0, 0, rect.w, rect.h}, false))
|
||||
{
|
||||
timer = getTicks();
|
||||
message = new StaticText(this, {0, rect.h/2, rect.w, PAGE_LINE_HEIGHT}, "", 0, CENTERED | FONT(L) | COLOR_THEME_PRIMARY1);
|
||||
setSelected(0);
|
||||
}
|
||||
|
||||
FileCarosell::~FileCarosell()
|
||||
{
|
||||
}
|
||||
|
||||
void FileCarosell::setFileNames(std::vector<std::string> fileNames)
|
||||
{
|
||||
_fileNames = fileNames;
|
||||
@@ -51,23 +46,20 @@ void FileCarosell::setFileNames(std::vector<std::string> fileNames)
|
||||
|
||||
void FileCarosell::setSelected(int n)
|
||||
{
|
||||
if (n == selected) return;
|
||||
if (n != selected) {
|
||||
selected = n;
|
||||
|
||||
if (n >= 0 && n < (int)_fileNames.size()) {
|
||||
fp->setFile(_fileNames[selected].c_str());
|
||||
} else
|
||||
fp->setFile("");
|
||||
}
|
||||
|
||||
selected = n;
|
||||
|
||||
if (n >= 0 && n < (int)_fileNames.size()) {
|
||||
fp->setFile(_fileNames[selected].c_str());
|
||||
} else
|
||||
fp->setFile("");
|
||||
}
|
||||
|
||||
void FileCarosell::paint(BitmapBuffer *dc)
|
||||
{
|
||||
if (selected == -1 || _fileNames.size() == 0) {
|
||||
const char *message = selected == -1 && _fileNames.size() > 0
|
||||
? "Loading..."
|
||||
: "No theme image";
|
||||
dc->drawText(width() / 2, height() / 2, message, FONT(L) + CENTERED);
|
||||
if (selected == -1) {
|
||||
lv_obj_clear_flag(message->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
message->setText(_fileNames.size() > 0 ? STR_LOADING : STR_NO_THEME_IMAGE);
|
||||
} else {
|
||||
lv_obj_add_flag(message->getLvObj(), LV_OBJ_FLAG_HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,15 +67,13 @@ void FileCarosell::checkEvents()
|
||||
{
|
||||
FormGroup::checkEvents();
|
||||
|
||||
uint32_t newTicks = getTicks();
|
||||
|
||||
// if we are paused then just update time. we will begin the carosell after
|
||||
// timeout period once unpaused
|
||||
if (_paused) {
|
||||
timer = getTicks();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t newTicks = getTicks();
|
||||
if (newTicks - timer > pageInterval && _fileNames.size()) {
|
||||
timer = newTicks;
|
||||
} else if (newTicks - timer > pageInterval && _fileNames.size()) {
|
||||
int newSelected = (selected + 1) % _fileNames.size();
|
||||
setSelected(newSelected);
|
||||
timer = newTicks;
|
||||
|
||||
@@ -32,7 +32,6 @@ class FileCarosell : public FormGroup
|
||||
public:
|
||||
FileCarosell(Window *parent, const rect_t &rect,
|
||||
std::vector<std::string> fileNames);
|
||||
~FileCarosell();
|
||||
|
||||
inline void setSelected(int n);
|
||||
void setFileNames(std::vector<std::string> fileNames);
|
||||
@@ -42,8 +41,6 @@ class FileCarosell : public FormGroup
|
||||
_paused = pause;
|
||||
}
|
||||
|
||||
void paint(BitmapBuffer *dc) override;
|
||||
|
||||
protected:
|
||||
bool _paused = false;
|
||||
int selected = -1;
|
||||
@@ -51,4 +48,5 @@ class FileCarosell : public FormGroup
|
||||
FilePreview *fp;
|
||||
uint32_t timer;
|
||||
uint32_t pageInterval = PAGE_INTERVAL;
|
||||
StaticText* message;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user