Date: | 2014-08-12 09:14:31 (9 years 7 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | a741653a13a7b3cb5848ee633272a81adbac2bc1 |
Message: | 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. |
Files: |
src/selector.cpp (6 diffs) src/selector.h (1 diff) |
Change Details
src/selector.cpp | ||
---|---|---|
85 | 85 | unsigned int firstElement = 0; |
86 | 86 | unsigned int selected = constrain(startSelection, 0, fl.size() - 1); |
87 | 87 | |
88 | vector<string> titles; | |
89 | prepare(&fl,&titles); | |
88 | prepare(fl); | |
90 | 89 | |
91 | 90 | auto folderIcon = gmenu2x->sc.skinRes("imgs/folder.png"); |
92 | 91 | if (!folderIcon) { |
... | ... | |
106 | 105 | |
107 | 106 | //Screenshot |
108 | 107 | if (fl.isFile(selected)) { |
109 | string& noext = titles[selected - fl.dirCount()]; | |
110 | string path = screendir + noext + ".png"; | |
108 | string path = screendir + trimExtension(fl[selected]) + ".png"; | |
111 | 109 | auto screenshot = OffscreenSurface::loadImage(path, "", false); |
112 | 110 | if (screenshot) { |
113 | 111 | screenshot->blitRight(s, 320, 0, 320, 240, 128u); |
... | ... | |
130 | 128 | top + (iY * fontheight) + (fontheight / 2), |
131 | 129 | Font::HAlignLeft, Font::VAlignMiddle); |
132 | 130 | } else |
133 | gmenu2x->font->write(s, titles[i - fl.dirCount()], 4, | |
131 | gmenu2x->font->write(s, trimExtension(fl[i]), 4, | |
134 | 132 | top + (iY * fontheight) + (fontheight / 2), |
135 | 133 | Font::HAlignLeft, Font::VAlignMiddle); |
136 | 134 | } |
... | ... | |
186 | 184 | dir = dir.substr(0,p+1); |
187 | 185 | selected = 0; |
188 | 186 | firstElement = 0; |
189 | prepare(&fl,&titles); | |
187 | prepare(fl); | |
190 | 188 | } |
191 | 189 | } |
192 | 190 | break; |
... | ... | |
203 | 201 | |
204 | 202 | selected = 0; |
205 | 203 | firstElement = 0; |
206 | prepare(&fl,&titles); | |
204 | prepare(fl); | |
207 | 205 | } |
208 | 206 | break; |
209 | 207 | |
... | ... | |
215 | 213 | return result ? (int)selected : -1; |
216 | 214 | } |
217 | 215 | |
218 | void Selector::prepare(FileLister *fl, vector<string> *titles) { | |
219 | fl->setPath(dir); | |
216 | void Selector::prepare(FileLister& fl) { | |
217 | fl.setPath(dir); | |
220 | 218 | |
221 | 219 | screendir = dir; |
222 | 220 | if (!screendir.empty() && screendir[screendir.length() - 1] != '/') { |
223 | 221 | screendir += "/"; |
224 | 222 | } |
225 | 223 | screendir += "previews/"; |
226 | ||
227 | titles->resize(fl->getFiles().size()); | |
228 | for (uint i=0; i<fl->getFiles().size(); i++) { | |
229 | titles->at(i) = trimExtension(fl->getFiles()[i]); | |
230 | } | |
231 | 224 | } |
src/selector.h | ||
---|---|---|
36 | 36 | LinkApp *link; |
37 | 37 | std::string file, dir, screendir; |
38 | 38 | |
39 | void prepare(FileLister *fl, std::vector<std::string> *titles); | |
39 | void prepare(FileLister& fl); | |
40 | 40 | |
41 | 41 | public: |
42 | 42 | Selector(GMenu2X *gmenu2x, LinkApp *link, |
Branches:
install_locations
master
opkrun
packages