mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-17 22:25:55 +02:00
Don't pre-strip file name extensions in Selector
This operation is not so slow that it really needs caching. Also reducing the delay before showing a directory will have more impact on the user experience than a slightly faster paint.
This commit is contained in:
parent
1e50dff746
commit
a741653a13
@ -85,8 +85,7 @@ int Selector::exec(int startSelection) {
|
|||||||
unsigned int firstElement = 0;
|
unsigned int firstElement = 0;
|
||||||
unsigned int selected = constrain(startSelection, 0, fl.size() - 1);
|
unsigned int selected = constrain(startSelection, 0, fl.size() - 1);
|
||||||
|
|
||||||
vector<string> titles;
|
prepare(fl);
|
||||||
prepare(&fl,&titles);
|
|
||||||
|
|
||||||
auto folderIcon = gmenu2x->sc.skinRes("imgs/folder.png");
|
auto folderIcon = gmenu2x->sc.skinRes("imgs/folder.png");
|
||||||
if (!folderIcon) {
|
if (!folderIcon) {
|
||||||
@ -106,8 +105,7 @@ int Selector::exec(int startSelection) {
|
|||||||
|
|
||||||
//Screenshot
|
//Screenshot
|
||||||
if (fl.isFile(selected)) {
|
if (fl.isFile(selected)) {
|
||||||
string& noext = titles[selected - fl.dirCount()];
|
string path = screendir + trimExtension(fl[selected]) + ".png";
|
||||||
string path = screendir + noext + ".png";
|
|
||||||
auto screenshot = OffscreenSurface::loadImage(path, "", false);
|
auto screenshot = OffscreenSurface::loadImage(path, "", false);
|
||||||
if (screenshot) {
|
if (screenshot) {
|
||||||
screenshot->blitRight(s, 320, 0, 320, 240, 128u);
|
screenshot->blitRight(s, 320, 0, 320, 240, 128u);
|
||||||
@ -130,7 +128,7 @@ int Selector::exec(int startSelection) {
|
|||||||
top + (iY * fontheight) + (fontheight / 2),
|
top + (iY * fontheight) + (fontheight / 2),
|
||||||
Font::HAlignLeft, Font::VAlignMiddle);
|
Font::HAlignLeft, Font::VAlignMiddle);
|
||||||
} else
|
} else
|
||||||
gmenu2x->font->write(s, titles[i - fl.dirCount()], 4,
|
gmenu2x->font->write(s, trimExtension(fl[i]), 4,
|
||||||
top + (iY * fontheight) + (fontheight / 2),
|
top + (iY * fontheight) + (fontheight / 2),
|
||||||
Font::HAlignLeft, Font::VAlignMiddle);
|
Font::HAlignLeft, Font::VAlignMiddle);
|
||||||
}
|
}
|
||||||
@ -186,7 +184,7 @@ int Selector::exec(int startSelection) {
|
|||||||
dir = dir.substr(0,p+1);
|
dir = dir.substr(0,p+1);
|
||||||
selected = 0;
|
selected = 0;
|
||||||
firstElement = 0;
|
firstElement = 0;
|
||||||
prepare(&fl,&titles);
|
prepare(fl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -203,7 +201,7 @@ int Selector::exec(int startSelection) {
|
|||||||
|
|
||||||
selected = 0;
|
selected = 0;
|
||||||
firstElement = 0;
|
firstElement = 0;
|
||||||
prepare(&fl,&titles);
|
prepare(fl);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -215,17 +213,12 @@ int Selector::exec(int startSelection) {
|
|||||||
return result ? (int)selected : -1;
|
return result ? (int)selected : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selector::prepare(FileLister *fl, vector<string> *titles) {
|
void Selector::prepare(FileLister& fl) {
|
||||||
fl->setPath(dir);
|
fl.setPath(dir);
|
||||||
|
|
||||||
screendir = dir;
|
screendir = dir;
|
||||||
if (!screendir.empty() && screendir[screendir.length() - 1] != '/') {
|
if (!screendir.empty() && screendir[screendir.length() - 1] != '/') {
|
||||||
screendir += "/";
|
screendir += "/";
|
||||||
}
|
}
|
||||||
screendir += "previews/";
|
screendir += "previews/";
|
||||||
|
|
||||||
titles->resize(fl->getFiles().size());
|
|
||||||
for (uint i=0; i<fl->getFiles().size(); i++) {
|
|
||||||
titles->at(i) = trimExtension(fl->getFiles()[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ private:
|
|||||||
LinkApp *link;
|
LinkApp *link;
|
||||||
std::string file, dir, screendir;
|
std::string file, dir, screendir;
|
||||||
|
|
||||||
void prepare(FileLister *fl, std::vector<std::string> *titles);
|
void prepare(FileLister& fl);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Selector(GMenu2X *gmenu2x, LinkApp *link,
|
Selector(GMenu2X *gmenu2x, LinkApp *link,
|
||||||
|
Loading…
Reference in New Issue
Block a user