mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 15:47:39 +03:00
Wrap-around FontSelectionActivity.cpp, hiding /fonts
Wrap-around navigation in FontSelection, normalization of selected font box appearance, hiding /fonts in file browser
This commit is contained in:
parent
2571d1ff58
commit
0e741a97e5
@ -46,6 +46,10 @@ void FileSelectionActivity::loadFiles() {
|
|||||||
file.close();
|
file.close();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (name[0] == '.' || strcmp(name, "fonts") == 0) {
|
||||||
|
file.close();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
files.emplace_back(std::string(name) + "/");
|
files.emplace_back(std::string(name) + "/");
|
||||||
|
|||||||
@ -51,29 +51,13 @@ void FontSelectionActivity::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mappedInput.wasPressed(MappedInputManager::Button::Up) ||
|
if (mappedInput.wasPressed(MappedInputManager::Button::Up) ||
|
||||||
mappedInput.wasPressed(MappedInputManager::Button::Left) ||
|
mappedInput.wasPressed(MappedInputManager::Button::Left)) {
|
||||||
mappedInput.wasPressed(MappedInputManager::Button::PageBack)) {
|
selectedIndex = (selectedIndex > 0) ? (selectedIndex - 1) : ((int)fontFamilies.size() - 1);
|
||||||
if (selectedIndex > 0) {
|
|
||||||
selectedIndex--;
|
|
||||||
if (selectedIndex < scrollOffset) {
|
|
||||||
scrollOffset = selectedIndex;
|
|
||||||
update = true;
|
update = true;
|
||||||
} else {
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mappedInput.wasPressed(MappedInputManager::Button::Down) ||
|
} else if (mappedInput.wasPressed(MappedInputManager::Button::Down) ||
|
||||||
mappedInput.wasPressed(MappedInputManager::Button::Right) ||
|
mappedInput.wasPressed(MappedInputManager::Button::Right)) {
|
||||||
mappedInput.wasPressed(MappedInputManager::Button::PageForward)) {
|
selectedIndex = (selectedIndex < (int)fontFamilies.size() - 1) ? (selectedIndex + 1) : 0;
|
||||||
if (selectedIndex < (int)fontFamilies.size() - 1) {
|
|
||||||
selectedIndex++;
|
|
||||||
if (selectedIndex >= scrollOffset + itemsPerPage) {
|
|
||||||
scrollOffset = selectedIndex - itemsPerPage + 1;
|
|
||||||
update = true;
|
update = true;
|
||||||
} else {
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) {
|
if (mappedInput.wasPressed(MappedInputManager::Button::Confirm)) {
|
||||||
@ -120,7 +104,7 @@ void FontSelectionActivity::render() const {
|
|||||||
// Draw selection box
|
// Draw selection box
|
||||||
if (idx == selectedIndex) {
|
if (idx == selectedIndex) {
|
||||||
Serial.printf("[FSA] Drawing selected: %s at %d\n", fontFamilies[idx].c_str(), y);
|
Serial.printf("[FSA] Drawing selected: %s at %d\n", fontFamilies[idx].c_str(), y);
|
||||||
renderer.fillRect(10, y - 2, 460, 24);
|
renderer.fillRect(0, y - 2, 480, 30);
|
||||||
renderer.drawText(UI_10_FONT_ID, 20, y, fontFamilies[idx].c_str(), false); // false = white (on black box)
|
renderer.drawText(UI_10_FONT_ID, 20, y, fontFamilies[idx].c_str(), false); // false = white (on black box)
|
||||||
} else {
|
} else {
|
||||||
Serial.printf("[FSA] Drawing: %s at %d\n", fontFamilies[idx].c_str(), y);
|
Serial.printf("[FSA] Drawing: %s at %d\n", fontFamilies[idx].c_str(), y);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user