File browser and track browser bug fixes

custom
ailurux 12 months ago
parent eeb3f2d406
commit 8019c76918
  1. 21
      lua/widgets.lua
  2. 3
      src/lua/file_iterator.cpp
  3. 1
      src/lua/include/file_iterator.hpp

@ -288,13 +288,8 @@ function widgets.RecyclerList(parent, iterator, opts)
end end
btn:onevent(lvgl.EVENT.FOCUSED, function() btn:onevent(lvgl.EVENT.FOCUSED, function()
if refreshing then return end if refreshing then return end
selected = this_item if this_item > last_selected and this_item - first_index > 5 then
if this_item > last_selected and this_item > 3 then
-- moving forward -- moving forward
if moving_back == true then
fwd_iterator:next()
moving_back = false
end
local to_add = fwd_iterator:next() local to_add = fwd_iterator:next()
if to_add then if to_add then
remove_top() remove_top()
@ -303,17 +298,13 @@ function widgets.RecyclerList(parent, iterator, opts)
end end
if this_item < last_selected then if this_item < last_selected then
-- moving backward -- moving backward
if last_index - this_item > 3 then if (last_index - first_index > 10) then
if moving_back == false then
-- Special case for the element we switch on
bck_iterator:prev()
moving_back = true
end
if (last_index > 10) then
remove_last() remove_last()
end end
if (first_index > 0) then if (first_index > 0 and this_item - first_index < 5) then
add_item(bck_iterator:prev(), first_index-1) local to_add = bck_iterator:prev();
if to_add then
add_item(to_add, first_index-1)
end end
end end
end end

@ -50,7 +50,7 @@ auto FileIterator::prev() -> void {
f_rewinddir(&dir_); f_rewinddir(&dir_);
auto new_offset = offset_-1; auto new_offset = offset_-1;
offset_ = -1; offset_ = -1;
for (int i = 0; i < new_offset; i++) { for (int i = 0; i <= new_offset; i++) {
iterate(false); iterate(false);
} }
} }
@ -73,6 +73,7 @@ auto FileIterator::iterate(bool reverse) -> bool {
// Update current value // Update current value
offset_++; offset_++;
current_ = FileEntry{ current_ = FileEntry{
.index = offset_,
.isHidden = (info.fattrib & AM_HID) > 0, .isHidden = (info.fattrib & AM_HID) > 0,
.isDirectory = (info.fattrib & AM_DIR) > 0, .isDirectory = (info.fattrib & AM_DIR) > 0,
.isTrack = false, // TODO .isTrack = false, // TODO

@ -16,6 +16,7 @@ namespace database {
// Note for when reading FILINFO, that we are in LFN mode: // Note for when reading FILINFO, that we are in LFN mode:
// http://elm-chan.org/fsw/ff/doc/sfileinfo.html // http://elm-chan.org/fsw/ff/doc/sfileinfo.html
struct FileEntry { struct FileEntry {
int index;
bool isHidden; bool isHidden;
bool isDirectory; bool isDirectory;
bool isTrack; bool isTrack;

Loading…
Cancel
Save